我应该在哪里为我的应用程序生成临时文件?

时间:2023-01-13 23:20:17

I've been warned by several people not to store temporary files in the Temporary Internet Files directory. Where would be the best place to store any temporary or log files that my application generates?

我被几个人警告不要将临时文件存储在Temporary Internet Files目录中。哪里是存储我的应用程序生成的任何临时文件或日志文件的最佳位置?

3 个解决方案

#1


You best bet is to use isolated storage for temp files, but you can also use GetTempFileName.

最好的办法是对临时文件使用独立存储,但也可以使用GetTempFileName。

#2


Is there a reason you can't use the default temporary directory? Essentially use the name returned from Path.GetTempFileName?

有没有理由你不能使用默认的临时目录?基本上使用从Path.GetTempFileName返回的名称?

#3


Temporary Internet Files folder is different from the TEMP folder. I agree about not using the Temporary Internet Files folder - it is meant for a different usage.

Temporary Internet Files文件夹与TEMP文件夹不同。我同意不使用Temporary Internet Files文件夹 - 它用于不同的用途。

The TEMP folder should be used for files that can be blown away without fear of crash.

TEMP文件夹应该用于可以在不担心崩溃的情况下被吹走的文件。

The TEMP folder, however, is no place for log files or configuration files or anything of importance. I would create my own folder under the user's profile preferably in the Application Data or Local Settings.

但是,TEMP文件夹不适用于日志文件或配置文件或任何重要的文件。我会在用户的配置文件下创建我自己的文件夹,最好是在应用程序数据或本地设置中。

#1


You best bet is to use isolated storage for temp files, but you can also use GetTempFileName.

最好的办法是对临时文件使用独立存储,但也可以使用GetTempFileName。

#2


Is there a reason you can't use the default temporary directory? Essentially use the name returned from Path.GetTempFileName?

有没有理由你不能使用默认的临时目录?基本上使用从Path.GetTempFileName返回的名称?

#3


Temporary Internet Files folder is different from the TEMP folder. I agree about not using the Temporary Internet Files folder - it is meant for a different usage.

Temporary Internet Files文件夹与TEMP文件夹不同。我同意不使用Temporary Internet Files文件夹 - 它用于不同的用途。

The TEMP folder should be used for files that can be blown away without fear of crash.

TEMP文件夹应该用于可以在不担心崩溃的情况下被吹走的文件。

The TEMP folder, however, is no place for log files or configuration files or anything of importance. I would create my own folder under the user's profile preferably in the Application Data or Local Settings.

但是,TEMP文件夹不适用于日志文件或配置文件或任何重要的文件。我会在用户的配置文件下创建我自己的文件夹,最好是在应用程序数据或本地设置中。