Can't delete file

  • Thread starter Thread starter Roger
  • Start date Start date
R

Roger

I keep getting a "File in use" error when I try to delete it from dotnet.
The file in question is an image file. Below follows the code I use:

File.SetAttributes(strFileName, FileAttributes.Normal)
File.Delete(strFileName)


Any ideas?
 
You must have some unmanaged code that opens the file somewhere else and
doesn't dispose of it. You might also trying something like this.

dim fi as new fileinfo(strFileName)
fi.delete()
 
Good call. When I called the dispose method of the image, it deleted
without a problem.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top