将文件写入临时文件夹
问题描述:
我想使用 StreamWriter
将文件写入临时文件夹。
I want to use StreamWriter
to write a file to the temp folder.
可能与众不同每台PC上的路径,所以我尝试使用%temp%\SaveFile.txt
但它没有用。
It might be a different path on each PC, so I tried using %temp%\SaveFile.txt
but it didn't work.
如何使用环境变量保存到临时文件夹?
How can I save to the temp folder, using environmental variables?
例如,我可以使用环境变量来存储中的文件%appdata%
?
And for example, can I use an environmental variable for storing files in %appdata%
?
答
string result = Path.GetTempPath();
http://msdn.microsoft.com/en-us/library/system.io.path.gettemppath(v = vs .110).aspx