Reputation: 11763
I am busy writing an application that runs under windows
Where is the correct place to save temporary files ?
Upvotes: 25
Views: 14628
Reputation: 12507
C:\Documents and Settings\username\Application Data\IsolatedStorage
Upvotes: -4
Reputation: 20198
If you are using .NET, please use Path.GetTempPath(). This will guarantee that you use the temporary directory assigned to the user that runs your application, regardless of where it is stored.
If you browse the file system, you will notice that there are many "temp" directories:
... and many more. Some of these paths are OS-dependent, and won't be present on certain windows flavors. So, save yourself some time and hassle, and let the .NET framework figure out where the "temp" path is located.
Upvotes: 42
Reputation: 1833
It depends on the language you are using:
string tempFolder = System.IO.Path.GetTempPath();
will return you the appropriate folder in C# for instance.
or, the environment variables TEMP or TMP if you must.
Upvotes: 3
Reputation: 55445
Use GetTempPath and and possibly GetTempFileName to determine where to put your temporary files. This is the most reliable, enduser-friendly, and future proof way to get a temporary location for files.
Upvotes: 12
Reputation: 150228
C:\Temp is NOT a good choice.
If you are using .Net use code like this:
string baseFolder = System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
string cfgFolder = Path.Combine(baseFolder, "MyAppName");
try
{
if (!Directory.Exists(cfgFolder))
{
Directory.CreateDirectory(cfgFolder);
}
}
catch { } // If no access, not much we can do.
to get a place for medium-term storage of app data, or Path.GetTempPath() for transient storage of data.
Upvotes: 5
Reputation: 281865
Use the GetTempPath API, or the equivalent for your programming environment.
Upvotes: 4
Reputation: 96177
In the temp directory?
Use GetTempPath or in a batch file %TEMP%
Upvotes: 6