Wednesday, March 28, 2012

System.IO.Path.GetTempFileName

Hi,
System.IO.Path.GetTempFileName( ) is supposed to create a temporary file and give us the path to the created file.
By default, where does this temp file get created? C:\Temp, C:\WinNT ?
Bcos right now this fails and error we get is "Access denied". But we dont know which folder's permissions to change as we dont know where this temp file is supposed to get created.

It will be in the ASPNET user's Temp Directory. For example, on mine:
C:\Documents and Settings\ComputerName\ASPNET\Local Settings\Temp


You are right ! I just found that out by using

tempPathString = Path.GetTempPath()
Thanks !


correctomundo!!
I know this is an old post, but System.IO.Path.GetTempPath() only puts stuff in the ASPNET user directory when the app runs on XP Pro. That is fine for development, but when the app is deployed to a Windows 2003 server the method returns C:\Windows\Temp. Calling GetTempFileName() creates a temp file there. Surely, it isn't safe or a best practice to write to the Windows directory, is it?

0 comments:

Post a Comment