DataFolder 1.1.0

dotnet add package DataFolder --version 1.1.0
                    
NuGet\Install-Package DataFolder -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DataFolder" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DataFolder" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="DataFolder" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DataFolder --version 1.1.0
                    
#r "nuget: DataFolder, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DataFolder@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DataFolder&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=DataFolder&version=1.1.0
                    
Install as a Cake Tool

DataFolder

A library that gives you a simple experience for saving user data.

Imagine this: you need to save user settings. And the routine begins:

  • Creating folders by hand
  • Checking for errors at every step
  • Figuring out how to store the data (JSON? Binary? Your own format?)
  • Writing code that has nothing to do with your actual task

DataFolder solves this problem with a simple and fast syntax.


📦 Installation

dotnet add package DataFolder

📁 Where data is stored

All data is saved into a .data folder inside the specified root path:

C:\myapp\.data\
        name.txt    → "Alex"
        level.txt   → "5"

By default, the root path is the folder where your application is running (AppContext.BaseDirectory). You can change it with SetRoot.


🚀 Quick start

using DataFolder;

var data = new DataManager();

// Make sure the .data folder exists (creates it if missing)
data.CheckDataFolder();

// Save a value
data.Set("name", "Alex");

// Read a value
string name = data.Get("name"); // "Alex"

📖 Syntax reference

Constructor

var data = new DataManager();

Creates a manager that points to .data next to your executable.


CheckDataFolder()

data.CheckDataFolder();

Creates the .data folder if it does not exist yet. Call this once before using Set / Get / Delete, unless you rely on Get(key, default, autoFile: true).


SetRoot(string rootPath)

data.SetRoot(@"C:\myapp\config");
// .data will now be created at C:\myapp\config\.data

Changes the base root. The .data subfolder is appended automatically.


Set(string key, string value)

data.Set("level", "5");

Writes value to the file named key inside .data. Overwrites the file if it already exists.


Get(string key)

string name = data.Get("name");

Reads the value for key. ⚠️ Throws InvalidOperationException if the key does not exist.


Get(string key, string defaultValue, bool autoFile) — new in 1.1.0 ✨

// If "theme.txt" doesn't exist → create it with "dark" and return "dark"
string theme = data.Get("theme", "dark", autoFile: true);

// If "theme.txt" doesn't exist → return "dark" but DON'T create the file
string theme = data.Get("theme", "dark", autoFile: false);

Reads the value for key. If the file doesn't exist:

autoFile Behaviour
true Creates the file with defaultValue and returns it.
false Returns defaultValue without touching the disk.

If the file does exist, its content is returned and defaultValue is ignored.


Delete(string key)

data.Delete("name");

Deletes the file for key. ⚠️ Throws InvalidOperationException if the key does not exist.


DeleteAll()

data.DeleteAll();

Wipes the entire .data folder and recreates it empty.


RootPath (read-only property)

Console.WriteLine(data.RootPath); // C:\myapp\.data

Returns the current absolute path to the .data folder.


💡 Examples

Storing user settings with defaults

var data = new DataManager();
data.CheckDataFolder();

string theme  = data.Get("theme",  "light", autoFile: true);
string volume = data.Get("volume", "50",    autoFile: true);

data.Set("theme", "dark");

Switching the storage location

var data = new DataManager();
data.SetRoot(Path.Combine(
    Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
    "MyApp"));
data.CheckDataFolder();

data.Set("token", "abc123");

📄 License

MIT

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 85 9/17/2026
1.0.0 86 9/14/2026