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
 
Back
Top