Writing File to Temp Folder

后端 未结 5 924
别那么骄傲
别那么骄傲 2020-12-08 13:14

I want to use StreamWriter to write a file to the temp folder.

It might be a different path on each PC, so I tried using %temp%\\SaveFile.txt

5条回答
  •  青春惊慌失措
    2020-12-08 13:21

    You can dynamically retrieve a temp path using as following and better to use it instead of using hard coded string value for temp location.It will return the temp folder or temp file as you want.

    string filePath = Path.Combine(Path.GetTempPath(),"SaveFile.txt");
    

    or

    Path.GetTempFileName();
    

提交回复
热议问题