I have a Web Service that calls another Executable which fetches a list of files and stores them at a temporary location, which will in turn be read by the web service.
I thought i will use the system's temp folder and found out that i could use System.IO.Path.GetTempPath
function to get the temp folder and store my files here. But when i checked the output returned by this function it gave me
C:\Users\username\AppData\Local\Temp\15\
i am worried about the \15 at the end of the path. Does this mean that the temp folder returned by GetTempPath is not constant and keeps changing? I need it to be constant since i need the web service to read from the temp files output by the executable
The documentation says:
This method checks for the existence of environment variables in the following order and uses the first path found:
1.The path specified by the TMP environment variable.
The path specified by the TEMP environment variable.
The path specified by the USERPROFILE environment variable.
The Windows directory.
So unless you change your environment the result is stable.
(Environment changes can occur, if you run as a service account, which never did an interactive logon), which has a default %SystemRoot%\Temp folder. If someone logs on to the server with this service account, a profile is created and the temp path will change)
Even if this post is somewhat older, I would like to share knowledge :-)
When running on a Terminalserver it is the default behavior of Windows to create a separate temporary subfolder for every connection to this server. There are ways to affect this but before you want to do this I would recommend to place your files somewhere else.
(http://blogs.msdn.com/b/oldnewthing/archive/2011/01/25/10119675.aspx)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With