File Handle not being released with FileInfo.LastWriteTime

  • Thread starter Thread starter dotnet_ottawa
  • Start date Start date
D

dotnet_ottawa

From an ASPX page I am trying to access the System.IO.FileInfo.LastWriteTime
property of a file on the web site.

The problem I have is that image file types; e/g/ gif, bmp etc; are not
being released from the FileInfo object. If I access a page that reads the
LastWriteTime of an image file; I cannot then update the file on the web
server, until the app pool recycles.

The same is not true for the text files; e.g. css, js; the FileInfo object
is releasing these files.

I have tried the garbage collector against the FileInfo object instance; but
this did not work.

Using the static System.IO.File object causes the same behaviour, and with
no instance to dispose of.

Does anyone know how to access a file's LastWriteTime [last modified]
property and release the handle?
 
Problem solved.

It was not the file property read that was causing the problem, but a
FileStream object elsewhere in the code that was not closed.
 
Back
Top