I wrote code that should write the file to the temp directory, and then copy it to a permanent location, but find that this creates a copy rights error. The code is as follows:
string tempPath = Path.GetTempFileName();
Stream theStream = new FileStream(tempPath, FileMode.Create);
File.Copy(tempPath, _CMan.SavePath, true);
File.Delete(tempPath);
I vaguely remember that there is an API call that I can create to create a temporary file in the specified directory, passed as a parameter. But, what a dull memory from my VB 6 days.
So, how do I create a temporary file in a directory other than the temporary directory defined by Windows?
source
share