0

I have a simple question (I think) that I'm not making much progress finding an answer to with Google. I have a structure as follows:

/// <summary>
/// A class to represent the sync settings for a single camera.
/// </summary>
public class CameraSyncSettings
{
    public string ID { get; set; }
    public string SyncPath { get; set; }
    public bool OverwriteExisting { get; set; }
};

And then an array of these in the program, one for each camera:

List<CameraSyncSettings> MyCameraSettings = new List<CameraSyncSettings>();

Now, what I want to do is have a property in my settings such that I can read/write this array into it to persist the information between sessions.

How can I do this and what is the best/most efficient way?

4

2 回答 2

1

您可以通过使用 ListDictionary 类型的 Properties.Settings 来实现它

    Example:
    Properties.Settings.Default.Example.Add("Setting1", new CameraSyncSettings());
    Properties.Settings.Default.Example.Add("Setting2", new CameraSyncSettings());
    Properties.Settings.Default.Example.Add("Setting3", new CameraSyncSettings());

    Properties.Settings.Default.Save();

有关更多信息,请参阅链接:http: //msdn.microsoft.com/en-us/library/aa730869 (v=vs.80).aspx

注意:您可以将 Properties.Settings.Default.Example 的范围设置为 Application 或 User

于 2012-07-05T10:50:05.990 回答
0

正如我们在您想要使用 app.config 的评论中清除的那样:这个项目应该几乎可以满足您的所有需求。

于 2012-07-05T10:35:07.403 回答