My winform app uses xml files to store data, where should I store them so Vista users can write to them?

前端 未结 6 897
后悔当初
后悔当初 2021-01-07 00:30

My winform app uses xml files to store data, where should I store them so Vista users can write to them?

Thanks

6条回答
  •  旧时难觅i
    2021-01-07 00:41

    Environment.GetFolderPath should tell you where Windows would like you to store things.

    For user-specific data,

    Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
    

    typically returns C:\Users\%user%\AppData\Roaming

    For common data,

    Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData));
    

    typically returns C:\ProgramData.

    This will also do the right thing under older flavours of Windows; XP will typically return C:\Documents and Settings\%user%\Application Data and C:\Documents and Settings\All Users\Application Data.

提交回复
热议问题