I have an application that downloads a file from FTP, reads the file, then deletes it (i download a temporary file because the stream gets disposed before i read the end of the data and i get an exception) and I was wondering what is the programming convention for storing temporary files? Basically right now I just download the file to the desktop directory (testing phase still) so it pops up on the desktop for a second while it's read then deleted.
Asked
Active
Viewed 1,139 times
1
-
[This](http://stackoverflow.com/questions/324045/windows-temporary-files-behaviour-are-they-deleted-by-the-system) SO Q & A may be of value. – HABO Jan 22 '15 at 03:37
1 Answers
5
Use System.IO.Path.GetTempFileName()
to get a randomly named file in the system's temp directory. Download to there.
Be sure to use System.IO.File.Delete()
when you're done with it!
https://msdn.microsoft.com/en-us/library/system.io.path.gettempfilename%28v=vs.110%29.aspx

Erik
- 5,355
- 25
- 39