Re: System.IO.Directory.Delete - access denied exception
- From: "Pharaon" <rybalkinsp@xxxxxxxxx>
- Date: 26 Sep 2006 00:56:28 -0700
MojoHand wrote:
I'm a new C# user, hoping for some insight to how/why this is
happening.
I'm having trouble with System.IO.Directory.Delete. Here is the
section of code that I'm struggling with:
string path = string.Format("\\\\{0}\\c$\\Documents and
Settings\\{1}\\", host, username);
if (System.IO.Directory.Exists(path))
{
System.Console.WriteLine("{0} is on {1}.", username, host);
System.IO.Directory.Delete(path, true);
}
This works on test cases to several levels. When I try to remove the
profile on other, network-connected machines I recieve the following
error:
Unhandled Exception: System.IO.IOException: Access to the path
'\\10.x.y.z\c$\Documents and Settings\testuser\Application
Data\Microsoft\Internet Explorer\Quick Launch' is denied.
at System.IO.Directory.DeleteHelper(String fullPath, String
userPath, Boolean recursive)
at System.IO.Directory.Delete(String fullPath, String userPath,
Boolean recursive)
at CmdProfKill.Program.Run()
at CmdProfKill.Program.Main()
I am able to delete the directory via Windows explorer, and am able to
do a rmdir \\'\\10.x.y.z\c$\Documents and Settings\testuser\' from a
command prompt. I have tried logging in as local admin and domain
admin priv's, same error each time. The local admin group has full
control priv's to the directory that says is denied.
Any thoughts would be greatly appreciated.
--Greg
Hi Greg,
I had the similar problem in ASP.NET application under Win2k3 server.
System.IO.Directory.Delete requires some extended access levels by
default, so maybe you should try to use build-in win32 function through
DllImport attribute. It worked for me.
.
- References:
- System.IO.Directory.Delete - access denied exception
- From: MojoHand
- System.IO.Directory.Delete - access denied exception
- Prev by Date: Getting unescaped XML from a transform
- Next by Date: Confused about System.Collections.IEnumerator
- Previous by thread: System.IO.Directory.Delete - access denied exception
- Next by thread: Re: System.IO.Directory.Delete - access denied exception
- Index(es):
Relevant Pages
|