正确的位置保存在临时文件? [英] Correct location to save a temporary file in Windows?

查看:111
本文介绍了正确的位置保存在临时文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文件,我需要写一个临时位置,什么是Windows最好的地方?此文件需要我需要阅读它几次和处置它,当我关闭程序不动了。

I have a file I need to write to a temp location, what is the best place in Windows? This file needs to not move as I need to read it a couple of times and dispose it when I close the program.

推荐答案

使用

Path.GetTempPath();

Path.GetTempFileName();

作为评论员指出,GetTempFileName()不是线程安全 - 但你可以构建基于GUID的唯一的文件名

As commentator pointed out, GetTempFileName() is not threadsafe - but you can construct unique file names based on GUIDs.

这篇关于正确的位置保存在临时文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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