FileInfo NameSpace and methods

  • Thread starter Thread starter Do
  • Start date Start date
D

Do

Hi,

I'm getting the following error messages "The process cannot access the
file "c:\inetpub\wwwroot\nspi1.5\files\DSCF0009.jpg" because it is being
used by another process."

This happens when I call the following code. Am I forgetting the clean up
something?

If objFile.Exists(Current.Server.MapPath("../files/" & filename)) Then

'Delete the physical file

objFile.Delete(Current.Server.MapPath("../files/" & filename))

Return True

Else

Current.Session.Contents("error") = "Physical file does not exist."

Return False

End If
 
hi,
Generally, this problem arises if your IIS holds the File
handle resource due to some malicious code i mean not
closing the filestream or file system object. Some times,
even due to some other problem the code behaves
indifferently. Hence better use some Try catch Exceptions,
so, that we can clean the code properly. The basic step
which we need to do for this is to Restart the IIS.

This happens many times to me. My idea to this is better
go for the proper exception handling.

thanks
srinivas moorthy
 
Back
Top