What determines the return value of Path.GetTempPath()?

后端 未结 6 395
忘了有多久
忘了有多久 2020-12-08 13:20

Currently, I use Path.GetTempPath() to figure out where to write my log files, but recently I came across a user\'s machine where the path returned was not what

6条回答
  •  爱一瞬间的悲伤
    2020-12-08 13:33

    Please try using the following to determine good place for Your data:

    Environment.GetFolderPath(Environment.SpecialFolder folder);
    

    Where Specialfolder

    // Summary:
    //     Specifies enumerated constants used to retrieve directory paths to system
    //     special folders.
    [ComVisible(true)]
    public enum SpecialFolder
    {
      // Summary:
      //     The logical Desktop rather than the physical file system location.
      Desktop = 0,
      //
      // Summary:
      //     The directory that contains the user's program groups.
      Programs = 2,
      //
      // Summary:
      //     The directory that serves as a common repository for documents.
      Personal = 5,
      //
      // Summary:
      //     The "My Documents" folder.
      MyDocuments = 5,
      //
      // Summary:
      //     The directory that serves as a common repository for the user's favorite
      //     items.
      Favorites = 6,
      //
      // Summary:
      //     The directory that corresponds to the user's Startup program group.
      Startup = 7,
      //
      // Summary:
      //     The directory that contains the user's most recently used documents.
      Recent = 8,
      //
      // Summary:
      //     The directory that contains the Send To menu items.
      SendTo = 9,
      //
      // Summary:
      //     The directory that contains the Start menu items.
      StartMenu = 11,
      //
      // Summary:
      //     The "My Music" folder.
      MyMusic = 13,
      //
      // Summary:
      //     The directory used to physically store file objects on the desktop.
      DesktopDirectory = 16,
      //
      // Summary:
      //     The "My Computer" folder.
      MyComputer = 17,
      //
      // Summary:
      //     The directory that serves as a common repository for document templates.
      Templates = 21,
      //
      // Summary:
      //     The directory that serves as a common repository for application-specific
      //     data for the current roaming user.
      ApplicationData = 26,
      //
      // Summary:
      //     The directory that serves as a common repository for application-specific
      //     data that is used by the current, non-roaming user.
      LocalApplicationData = 28,
      //
      // Summary:
      //     The directory that serves as a common repository for temporary Internet files.
      InternetCache = 32,
      //
      // Summary:
      //     The directory that serves as a common repository for Internet cookies.
      Cookies = 33,
      //
      // Summary:
      //     The directory that serves as a common repository for Internet history items.
      History = 34,
      //
      // Summary:
      //     The directory that serves as a common repository for application-specific
      //     data that is used by all users.
      CommonApplicationData = 35,
      //
      // Summary:
      //     The System directory.
      System = 37,
      //
      // Summary:
      //     The program files directory.
      ProgramFiles = 38,
      //
      // Summary:
      //     The "My Pictures" folder.
      MyPictures = 39,
      //
      // Summary:
      //     The directory for components that are shared across applications.
      CommonProgramFiles = 43,
    }
    

提交回复
热议问题