File and directory permissions error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I'd really appreciate some help resolving the System.UnauthorizedAccessException that I receive when performing certain actions (I'm using C# with the .NET Framework 1.1). The File.Copy(source, dest, true) function works fine if the destination file does not exist, but if it does I receive this error (despite the fact that the 'overwrite' parameter is set). The same error occurs when I try to delete files and directories (eg. Directory.Delete(path, true)). And I do have the necessary permissions! I can easily delete or replace the files with Windows Explorer.

Please help, and many thanks in advance,


James.
 
Hello James,

Thanks for your post. As I understand, the problem you are facing is that
you cannot delete files and directories in your C# application with
UnauthorizedAccessException. Please correct me if there is any
misunderstanding. I think more information is needed before moving forward:

1. Does the problem occurs to a specific directory or to all
files/directories in your system?

2. Did you keep the file open somewhere else in your application when you
attempt to delete it?

3. Where does the executable file of your application locates, on local
harddrive or on remote network share? If it resides on remote network
share, please set LocalIntranet_Zone to FullTrust permission in .NET
Configuration tool, and then check if it works.

I look forward to your response.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Thanks for your reply. In response to your queries

1) The problem appears to occur in all directories. I have tried deleting "C:\Program Files\TMI Management Centre", and "C:\test", both folders which were created by the same program, and the same error occurs each time

2) I'm certain that the files aren't open anywhere else

3) The executable file is located at "C:\Documents and Settings\James Gurung\My Documents\Visual Studio Projects\TMIUpdate\bin\Release\TMISetup.exe", and the local intranet is set to FullTrust permission anyway

Many thanks

James.
 
Hello James,

Thanks for your prompt response. This issue seems strange. I suggest you to
create a new .NET console applicaiton with File.Delete and Directory.Delete
only to check if it is able to delete the files and directories.

In addition, could you please open Windows Explorer, right-click the files
or directories, choose "Properties", make sure they are not "Read-only". If
your file system is NTFS, please also check the security to make sure the
currently logged on account has enough privilige.

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top