Path.GetTempFileName throws Exception (The file exists)

今天使用Path.GetTempFileName创建临时文件,抛出了exception:System.IO.IOException: The file exists。看了一下MSDN,

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.

然后去临时文件夹看了一下,证实是由于文件太多了,已经到了tmpFFFF.tmp。也没有查到系统处理这些临时文件的机制,只能手动删掉或者在代码里先处理一下了。

删除临时文件的batch command:

cd C:\Users\%username%\AppData\Local

del *.tmp /Q

posted @ 2011-07-06 10:33  KymoWang  阅读(1398)  评论(0编辑  收藏  举报