I'm having some major trouble deleting directories. I'm working building a ADMIN tool to delete directories that my clients create but then ask to delete them. You would think this is simple:
using (var context = Impersonator.LogOn(user, password, domain))
{
try
{
dir = new DirectoryInfo(path);
dir.Delete(true);
}
catch (Exception ex)
{
return string.Format("Error:{0}", ex.Message);
}
finally
{
context.Undo();
}
}
Now no matter what I do I can't delete the folder. response is alway "Access to the path is denied". I've doubled check the path, the login everything.
Please tell me what I'm doing wrong.
Server: win2008 web edition ASP.NET: 4