Where is the correct place to store my application specific data?

后端 未结 3 1522
傲寒
傲寒 2020-12-14 00:16

I\'m developing a small C# Winforms game and one of the things I\'m wanting to do is save application specific data. However, I\'m struggling a bit to understand the correc

3条回答
  •  时光取名叫无心
    2020-12-14 01:11

    Application properties - Most application data you described should be specific to each user and put in Environment.SpecialFolder.ApplicationData (the %appdata% environment variable). I would generally avoid putting data in the registry as it is hard to find, edit, and fix. If you do not want data to be associated with the user when they are roaming (maybe the files are big or connected to the computer in someway) then you can put it in Environement.SpecialFolder.LocalApplicationData (the `%localappdata% environment variable).

    Global application data - I would put global application data in Environment.SpecialFolder.CommonApplicationData ( the %programdata% environment variable)

    User specific application data - Same as #1, except when the data is intended to be easily found by the user (e.g. saved games) in which case it should go in Environment.SpecialFolder.MyDocuments, which has no associated environment variable.

    As yas4891 points out you can reliably get these folder paths using Environment.GetFolderPath() using one of the Environment.SpecialFolder` values listed here.

提交回复
热议问题