Environment.GetFolderPath(…CommonApplicationData) is still returning “C:\Documents and Settings\” on Vista

后端 未结 5 445
北海茫月
北海茫月 2021-01-29 20:37

As I understand it, you\'re supposed to use the Environment.GetFolderPath method so you have OS independent code...

Windows XP uses C:\\Documents and

5条回答
  •  执念已碎
    2021-01-29 20:59

    Output on Windows 10

    Fonts: C:\Windows\Fonts
    CommonStartMenu: C:\ProgramData\Microsoft\Windows\Start Menu
    CommonPrograms: C:\ProgramData\Microsoft\Windows\Start Menu\Programs
    CommonStartup: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
    CommonDesktopDirectory: C:\Users\Public\Desktop
    CommonApplicationData: C:\ProgramData
    Windows: C:\Windows
    System: C:\Windows\system32
    ProgramFiles: C:\Program Files (x86)
    SystemX86: C:\Windows\SysWOW64
    ProgramFilesX86: C:\Program Files (x86)
    CommonProgramFiles: C:\Program Files (x86)\Common Files
    CommonProgramFilesX86: C:\Program Files (x86)\Common Files
    CommonTemplates: C:\ProgramData\Microsoft\Windows\Templates
    CommonDocuments: C:\Users\Public\Documents
    CommonAdminTools: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools
    CommonMusic: C:\Users\Public\Music
    CommonPictures: C:\Users\Public\Pictures
    CommonVideos: C:\Users\Public\Videos
    Resources: C:\Windows\resources
    LocalizedResources:
    CommonOemLinks:
    

    Code Snippet if you want to log your own

    foreach(Environment.SpecialFolder f in Enum.GetValues(typeof(Environment.SpecialFolder)))
    {
        string commonAppData = Environment.GetFolderPath(f);
        Console.WriteLine("{0}: {1}", f, commonAppData);
    }
    Console.ReadLine();
    

提交回复
热议问题