temp qus
temp qus

Reputation: 18

access denied while deleting file

while deleting its throwing error Access Denied ...

sSystemFolder = "c:\\";


 if (File.Exists(sSystemFolder + "\\Registry.txt"))

                {

                    File.Delete(sSystemFolder + "\\Registry.txt");
                    StreamWriter SW;
                    sSystemFolder = sSystemFolder + "\\Registry.txt"; ;
                    SW = File.CreateText(sSystemFolder);
                    SW.WriteLine(Rkey + ";" + Nofu + ";" + Date + ";" + Status);
                    SW.Close();
                }
                else
                {
                    StreamWriter SW;
                    sSystemFolder = sSystemFolder + "\\Registry.txt"; ;
                    SW = File.CreateText(sSystemFolder);
                    SW.WriteLine(Rkey + ";" + Nofu + ";" + Date + ";" + Status);
                    SW.Close();
                }

could anyone point me where is the error?

Upvotes: 0

Views: 101

Answers (1)

TomTom
TomTom

Reputation: 62093

No error. Access is denied. Check file access.

And realize that C: - system root - requires elevation to make anything. Not a good idea to store anything in that place. It is against best practices. The file should not be there.

Upvotes: 1

Related Questions