Advertisements

When creating a temp file System.IO.IOException: The file exists error

http://blog.dileno.com/archive/201103/fixing-the-file-exists-ioexception-error/

If you get the System.IO.IOException: The file exists error, it’s probably because your C:/Windows/Temp folder is absolutely full with temporary files. In fact, if you have more than 65535 files in your temp folder, the method GetTempFileName will throw this error.

To resolve this, just remove all temporary files in C:/Windows/Temp. It might take some time, but it will solve the problem.

Here’s the stack trace I got:

System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   System.IO.Path.GetTempFileName()

 

Advertisements

5 Responses

  1. […] this, I found plenty of blog posts stating this exception is thrown when there are more than 65535 temp files in the %TEMP% folder, […]

  2. I would recomend not using Path.GetTempFileName() at all. You have no guarantee that this method wil work over time. This is explained in detail in my blog: http://morten.bravonet.no/post/2013/10/07/PathGetTempFileName()-causes-The-file-exists-exception.aspx

  3. Run into this problem in Subtitle Edit. Have a bit of stack trace knowledge from Java so copying the topmost error message led me here.

    This trick made it go away so thank you.

  4. If you are running this command under a specific user you could check also the temp direcotry of your user profile usually in c:\Users\AppData\Local\Temp

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: