0

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?

  • Saving files from a .NET application can be done anywhere you want. What you're asking has nothing to do with WPF or any other type of project you've created. You can save it in a C:\Temp folder or save it into the project bin\Debug folder. It depends on your preference. – Gabriel Marius Popescu Feb 22 '22 at 16:02
  • I think you want to remove the word "temporary" from your question unless you want files to be automatically deleted after a system reboot or something like that. What makes these files temporary in your mind? You can find the _Downloads_ folder [like this](https://stackoverflow.com/a/21953690/1563833). – Wyck Feb 22 '22 at 16:09

2 Answers2

3

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.

TJ Rockefeller
  • 2,570
  • 16
  • 32
Joe
  • 3,885
  • 14
  • 35
0

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 
Palisar
  • 19
  • 4