在.Net winforms应用程序中,如何获取当前用户的临时文件夹的路径?

时间:2021-05-22 07:25:33

Seems so basic, I can't believe I don't know this! I just need a scratch folder to dump some temporary files to. I don't care if it gets wiped out between usages or not, and I don't think I should have to go through the hassle of creating one and maintaining it myself from within my application. Is that too much to ask?

似乎这么基本,我不敢相信我不知道这个!我只需要一个临时文件夹来转储一些临时文件。我不在乎它是否在使用之间被消除,我认为我不应该经历从我的应用程序中创建一个并自己维护它的麻烦。那是过分的要求?

3 个解决方案

#2


5  

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) or Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)或Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

#3


3  

This is for VB.NET

这是针对VB.NET的

My.Computer.FileSystem.SpecialDirectories.Temp

not sure if there's similar in C#

不确定C#中是否有相似之处

#1


#2


5  

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) or Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)或Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)

#3


3  

This is for VB.NET

这是针对VB.NET的

My.Computer.FileSystem.SpecialDirectories.Temp

not sure if there's similar in C#

不确定C#中是否有相似之处