CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2001
    Location
    South Korea
    Posts
    31

    How to get "Temp" folder path?

    How can I get "Temp" folder path with C#.

    I've looked up System.Environment.SpecialFolder,
    but "Temp" wasn't there.

    In win 9X the temp path is typically
    "C:\Windows\Temp"
    In windows 2000,XP
    "C:\\Windows\User Name\Local Settings\Temp


    My current dirty solution is,
    Code:
    			string tempinternet=System.Environment.GetFolderPath(
    				System.Environment.SpecialFolder.InternetCache);
    			string temppath=tempinternet.Substring(0,tempinternet.LastIndexOf("\\"))
    				+"\\temp";
    But is this safe?
    Last edited by Sin Jeong-hun; October 6th, 2002 at 10:16 PM.
    ALEA JACTA EST ET TEMPUS FUGIT

  2. #2
    Join Date
    May 2001
    Location
    Russia
    Posts
    200
    From VS.Net Help

    The following example code demonstrates the use of the GetTempPath method.

    string tempPath = Path.GetTempPath();
    Console.WriteLine("Temporary path is '{0}'", tempPath);
    Andy Tower

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured