Delete File!! HELP!!!

  • Thread starter Thread starter Iris
  • Start date Start date
I

Iris

Hi! I have a big problem. I have a database and textfiles.
Everytime a new textfile is saved to a folder this textfile
is read and saved to the database.
This works good .. but then I want to delete the file and
here it is over .. it says access to path denied.
What is the prob?? Could it be bec. it is read only?? How
can I change that?
 
yes, if you get a exceptionmessage like "access to path denied" then you
have a access-problem on the specified directory.
do you use csharp ASP.net?
if yes, there is a user ASPNET on your system which must have read and write
access to a directory to be able to read and write or delete.

try the following: open the properties of the specified directory and switch
to the security-tab. set "full control" to user Everyone and try it again.
but DONT FORGET to take off the rights again!

hope this helps
cheers, Jazper
 
Another cause can be if the file has just been accessed by the application.

i.e. its the same method that reads the file and then tries to delete it, or
at least in the same scope.

I think what happens is the operating system hasnt released its 'lock' in
the file yet.

Call Application.DoEvents just before the delete statement. I may be talking
out of my hat here but if your stuck its a simple thing to try and certainly
it got me out of a simalair situation :)
 
Back
Top