File.Delete UnauthorizedAccessException

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

Guest

I am not able to delete a .dll from my device programmatically. I can delete it manually (w/ the stylus) but the application gets an UnauthorizedAccessException. I am able to delete a .config file just fine

The file has no attributes checked, the file is not in use by another application

I am trying to delete the file and then download it from a webserver to update an application. If the file does not exist all goes well. If the file already exists I get the afore mentioned exception

Joh
 
This maybe a hint for you:
http://www.opennetcf.org/forums/topic.asp?TOPIC_ID=1500

John said:
I am not able to delete a .dll from my device programmatically. I can
delete it manually (w/ the stylus) but the application gets an
UnauthorizedAccessException. I am able to delete a .config file just fine.
The file has no attributes checked, the file is not in use by another application.

I am trying to delete the file and then download it from a webserver to
update an application. If the file does not exist all goes well. If the
file already exists I get the afore mentioned exception.
 
The best way is probably to check the error which caused the File.Delete to
fail. If you have some means of telling the code that you're planning to
update to exit before you do that, it might make sense to send that
'message', wait a short while, then try the delete and, if it fails, notify
the user or something. You might be able to get the process handle for the
process which is using the DLL, if you know which one it is, and wait on
that handle after sending the quit message, too.

Paul T.
 
The dll is not in use by any program that I am aware of

The application that does the update is a separate exe assembly which is a hybrid of the solution given in msdn http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/autoupdater.as

Instead of downloading a cab file I'm downloading the individual program file(s). This would allow the program to be updated w/o the interaction of the user to re-install the application from a cab

Again...the application which uses the dll I am trying to delete is not running when I try to delete it. I have no idea what else might be holding a thread on the dll

Joh
 
Well, let's see...the DLL is not in ROM? the DLL is not read-only?

Paul T.

John said:
The dll is not in use by any program that I am aware of.

The application that does the update is a separate exe assembly which is a
hybrid of the solution given in msdn
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/autoupdater.asp
Instead of downloading a cab file I'm downloading the individual program
file(s). This would allow the program to be updated w/o the interaction of
the user to re-install the application from a cab.
Again...the application which uses the dll I am trying to delete is not
running when I try to delete it. I have no idea what else might be holding
a thread on the dll.
 
Correct..

- The dll is not read-onl
- The dll is in RA

The only thing that I can think of is that the dll assembly is read from to get the version. But is then released. Does that sound like a problem to you? You can view the code in the article I gave the link to in my last post. I am using that method to read the assembly version

Joh
 
Back
Top