NTDLS.Persistence

Status: Stable
Released: 2024-12-31
License: MIT License

This is open source under the MIT License. You can obtain the source code from GitHub or browse the releases for source code associated with specific versions. If you make any changes which you feel improves this application, please feel free to submit a pull - request.

NTDLS.Persistence

📦 Be sure to check out the NuGet pacakge: https://www.nuget.org/packages/NTDLS.Persistence

Helpers for reading and writing serialized objects to/from files. Helpful for configuration files.

class UIPreferences
{
    public string Username { get; set; } = string.Empty;
    public bool RememberPassword { get; set; }
}

static void Main(string[] args)
{

    //Example of saving preferences:
    var preferences = new UIPreferences()
    {
        Username = "JPatterson",
        RememberPassword = false
    };

    //The file will be given the name of the class type and the given program 
    //  name and will be stored in the common programs data directory.
    CommonApplicationData.SaveToDisk("MyProgramName", preferences);

    //Exmaple loading preferences:
    var loadedPreferences = CommonApplicationData.LoadFromDisk<UIPreferences>("MyProgramName");
}