Home > Net >  Where and how save temporary files in WPF C# app
Where and how save temporary files in WPF C# app

Time:02-23

I am building a wpf c # application, at user request I download image files from DB (not designed by me). Where should I save these files so that I can open them later in the program?

CodePudding user response:

The simplest way is to just call Path.GetTempPath. This will give you a writable folder that is your temp folder. If you are looking for something specific like a windows Special folder then something like

Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)

(or some other SpecialFolder value will do.

CodePudding user response:

You can try adding a temp file like this:

string FileName = Path.GetTempFileName();
FileStream File_Stream = new FileStream(FileName, FileMode.Append, 
FileAccess.Write);
//Do what you like with this file 
  • Related