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

后端 未结 5 447
北海茫月
北海茫月 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:55

    My installer copied a log.txt file which had been generated on an XP computer. I was looking at that log file thinking it was generated on Vista. Once I fixed my log4net configuration to be "Vista Compatible". Environment.GetFolderPath was returning the expected results. Therefore, I'm closing this post.

    The following SpecialFolder path reference might be useful:

    Output On Windows Server 2003:

    SpecialFolder.ApplicationData: C:\Documents and Settings\blake\Application Data
    SpecialFolder.CommonApplicationData: C:\Documents and Settings\All Users\Application Data
    SpecialFolder.ProgramFiles: C:\Program Files
    SpecialFolder.CommonProgramFiles: C:\Program Files\Common Files
    SpecialFolder.DesktopDirectory: C:\Documents and Settings\blake\Desktop
    SpecialFolder.LocalApplicationData: C:\Documents and Settings\blake\Local Settings\Application Data
    SpecialFolder.MyDocuments: C:\Documents and Settings\blake\My Documents
    SpecialFolder.System: C:\WINDOWS\system32`
    

    Output on Vista:

    SpecialFolder.ApplicationData: C:\Users\blake\AppData\Roaming
    SpecialFolder.CommonApplicationData: C:\ProgramData
    SpecialFolder.ProgramFiles: C:\Program Files
    SpecialFolder.CommonProgramFiles: C:\Program Files\Common Files
    SpecialFolder.DesktopDirectory: C:\Users\blake\Desktop
    SpecialFolder.LocalApplicationData: C:\Users\blake\AppData\Local
    SpecialFolder.MyDocuments: C:\Users\blake\Documents
    SpecialFolder.System: C:\Windows\system32
    

提交回复
热议问题