Reputation: 2428
I have written a application with C#.But,I continually get an error message of "access denied" for "App Data" under my user profile (password protected user account).BTW,I'm using Win7.
Here is my code:
string path = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "//Programım//");
Upvotes: 0
Views: 3493
Reputation: 6646
I would use System.IO.Path.Combine(...)
instead of string.Conact(...)
in this situation. Like this...
string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Programım");
The result of path
in your original code might not be what you are actually expecting.
Once you are sure your path
value is correct then call System.IO.Directory.Delete(...)
like...
Directory.Delete(path, true);
If that still is not working, then there may be some other security permission problems with files in that directory, or with the directory itself. See the MSDN page for all of the exceptions that can be thrown from the Delete
method and the reasons why.
Upvotes: 1