I've written some code that is supposed to write a file to the temp directory, then copy it to a permanent location, but find that doing so creates a permission-related error on the copy command. The code looks like this:
string tempPath = Path.GetTempFileName();
Stream theStream = new FileStream(tempPath, FileMode.Create);
// Do stuff.
File.Copy(tempPath, _CMan.SavePath, true);
File.Delete(tempPath);
I dimly remember that there's an API call I can make to create a temp file in a specified directory, passed as a parameter. But, that's a dim memory from my VB 6 days.
So, how do I create a temp file in a directory other than the temp directory defined by Windows?