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
  • To clarify, what's the format of your "settings file"? Is it XML? Commented Jul 5, 2012 at 10:16
  • msdn.microsoft.com/en-us/library/… Commented Jul 5, 2012 at 10:16
  • It's the basic settings file you get with a C# project. You know the one that integrates with VS. Commented Jul 5, 2012 at 10:17
  • I know it as Settings.settings in the UI. Edit, which I guess becomes app.config... Commented Jul 5, 2012 at 10:20

2 Answers 2

1

You can achieve it by using Properties.Settings of type ListDictionary

    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();

see link for more information : http://msdn.microsoft.com/en-us/library/aa730869(v=vs.80).aspx

NB: You can set the Scope of Properties.Settings.Default.Example to Application or User

Sign up to request clarification or add additional context in comments.

Comments

0

As we've cleared in the comments you want to use app.config: this project should pretty much cover all your needs.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.