Windows 中 TEMP 目录的限制? [英] Limitations of TEMP directory in Windows?

查看:15
本文介绍了Windows 中 TEMP 目录的限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用 Python 编写的应用程序,它正在将大量数据写入 %TEMP% 文件夹.奇怪的是,它每隔一段时间就会死掉,返回 IOError: [Errno 28] No space left on device.驱动器有充足的可用空间,%TEMP%不是它自己的分区,我是管理员,系统没有配额.

I have an application written in Python that's writing large amounts of data to the %TEMP% folder. Oddly, every once and awhile, it dies, returning IOError: [Errno 28] No space left on device. The drive has plenty of free space, %TEMP% is not its own partition, I'm an administrator, and the system has no quotas.

Windows 是否人为地对 %TEMP% 中的数据设置了某些类型的限制?如果没有,您对可能导致此问题的原因有什么想法吗?

Does Windows artificially put some types of limits on the data in %TEMP%? If not, any ideas on what could be causing this issue?

编辑:在下面的讨论之后,我澄清了问题以更好地解释发生了什么.

EDIT: Following discussions below, I clarified the question to better explain what's going on.

推荐答案

您遇到的确切错误是什么?

What is the exact error you encounter?

您是否也在创造许多临时文件?

GetTempFileName 方法将引发一个 IOException 如果它被用来创建超过 65535 个文件删除以前的临时文件.

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

GetTempFileName 方法将引发如果没有唯一的临时值,则为 IOException文件名可用.解决这个错误,删除所有不需要的临时文件.

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

需要注意的一点是,如果您间接使用 Win32 API,并且仅使用它来获取临时文件名,请注意 while(间接)调用它:

One thing to note is that if you're indirectly using the Win32 API, and you're only using it to get temp file names, note that while (indirectly) calling it:

创建一个唯一命名的零字节磁盘上的临时文件并返回该文件的完整路径.

Creates a uniquely named, zero-byte temporary file on disk and returns the full path of that file.

如果您使用该路径但也更改了返回的值,请注意您实际上可能正在创建一个 0byte 文件和一个附加文件(例如 My_App_tmpXXXX.tmp 和 tmpXXXX.tmp).

If you're using that path but also changing the value returned, be aware you might actually be creating a 0byte file and an additional file on top of that (e.g. My_App_tmpXXXX.tmp and tmpXXXX.tmp).

正如下面 Nestor 建议的那样,请考虑在使用完临时文件后删除它们.

As Nestor suggested below, consider deleting your temp files after you're done using them.

这篇关于Windows 中 TEMP 目录的限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆