Wednesday, December 17, 2008

System.IO.IOException: The file exists and GetTempFileName solution and explanation

I was researching a problem in JTB FlexReport that a couple of customers had and the error log gave this error message.

System.IO.IOException: The file exists. 
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.__Error.WinIOError()
   at System.IO.Path.GetTempFileName()

It was pretty obvious that the file did not exist as the message said and thanks to this post I got the explanation as there also where “many” empty temp files (0 KB) in the c:\windows\temp folder.

The GetTempFileName method will raise an IOException if it is used to create more than 65535 files without deleting previous temporary files.

The GetTempFileName method will raise an IOException if no unique temporary file name is available. To resolve this error, delete all unneeded temporary files.

Eventually I found the problem and the solution will be included in the next release. It seems to affect very few customers but a hotfix is available in the meantime.

1 comment:

  1. oh please find the solution !!
    I have tha probleme and i've spent my 20 last hours to try to solve it... But noting to do, i a so disapointed.
    Thanks

    ReplyDelete