Search code examples
c#visual-studio-2008filetemp

Path.GetTempFileName() - can I change this to use a shared drive?


Using VS2008, c#.

When I call Path.GetTempFileName(), the temp file generated is something like: C:\Users\allensamuel\AppData\Local\Temp\tmpC1D0.tmp

However, in the company I work, using the C: drive for files is not prohibited. Rather, a login scrips points the user's "my documents" and "home" area (decouemtn and settings etc) are pointed to a networked "H:" drive.

I can't see why Path.GetTempFileName() is choosing the C: drive, or how to instruct it to use the H drive.

Any ideas? I don't really want to create my own version ofthe above method.


Solution

  • It chooses this path because it is set in %TEMP% environment variable. Try setting this variable to point somewhere around H drive.