MiJennerConfigUtilsFolderManager 1.1.0

Suggested Alternatives

MiJenner.ConfigUtils-FolderManager

Additional Details

Use the alternate package instead.

dotnet add package MiJennerConfigUtilsFolderManager --version 1.1.0
                    
NuGet\Install-Package MiJennerConfigUtilsFolderManager -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="MiJennerConfigUtilsFolderManager" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MiJennerConfigUtilsFolderManager" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="MiJennerConfigUtilsFolderManager" />
                    
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 MiJennerConfigUtilsFolderManager --version 1.1.0
                    
#r "nuget: MiJennerConfigUtilsFolderManager, 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 MiJennerConfigUtilsFolderManager@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=MiJennerConfigUtilsFolderManager&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=MiJennerConfigUtilsFolderManager&version=1.1.0
                    
Install as a Cake Tool

MiJenner.ConfigUtils-FolderManager

Desktop Folder Manager in cross platform C# for handling applications storage of user data and user configuration data. The system enables creation of a subfolder structure with .../YourCompany/YourApp/ ... where you can store data and or configuration files. On Windows the path could be: C:\Users\john\AppData\Roaming\YourCompany\YourApp On MacOS the path could be: /Users/john/.config/YourCompany/YourApp

Getting Started

Add using

Include the namespace:

using MiJenner.ConfigUtils;

Create configuration object

Next, use the configuration builder to build a configuration object:

var config = new DesktopFolderManagerConfigBuilder()
    .WithUserDataPolicy(UserDataPolicy.PolicyFileAppDataRoaming)
    .WithUserDataMagic("")
    .WithUserConfigPolicy(UserConfigPolicy.PolicyFileAppDataRoaming)
    .WithUserConfigMagic("")
    .WithCompanyAndAppName("YourCompany", "YourApp")
    .Build();

Policies

UserDataPolicy and UserConfigPolicy choose from the same list of the following enums / locations (if username is john):

  • PolicyFileAppDataLocal: Windows: C:\Users\john\AppData\Local, MacOS: /Users/john/.local/share, Linux: todo
  • PolicyFileAppDataRoaming: Windows: C:\Users\john\AppData\Roaming, MacOS: /Users/john/.config, Linux: todo
  • PolicyFileDesktop: Windows: C:\Users\john\Desktop, MacOS: /Users/john/Desktop, Linux: todo
  • PolicyFileDocument: Windows: C:\Users\john\Documents, MacOS: /Users/john/Documents, Linux: todo
  • PolicyFileUserProfile: Windows: C:\Users\john, MacOS: /Users/john, Linux: todo
  • PolicyFileTempPath: Windows: C:\Users\john\AppData\Local\Temp, MacOS: /var/folders/..., Linux: /tmp

Note: PolicyFileDocument and PolicyFileAppDataRoaming may not be accessible due to IT security restrictions, for example in school or corporate environments. In those cases, try PolicyFileUserProfile as a fallback, or PolicyFileTempPath as a last resort. Be aware that the temp folder may be cleared on logoff.

Create FolderManager instance

Next, you will typically create a FolderManager instance, based on the just created configuration:

var folderManager = new DesktopFolderManager(config);

Note: The constructor will throw ArgumentException if CompanyName or AppName is null or whitespace, and ArgumentNullException if config is null.

Try to create folders

And you would use some logic to determine proper folders for users data and for users configuration, which may be the same. And once found, you want to create them (if already existing this will not harm content). For user data this could be something like:

string dataFolder;
if (!folderManager.TryGetDataFolderPath(out dataFolder))
{
    // user data folder path could not be determined. 
    // logic to get out of that situation.
}
else
{
    // try to create user data folder: 
    if (!folderManager.TryCreateUserDataFolder())
    {
        // user data folder could not be created. 
        // logic to get out of that situation. 
    }
}

And if it differs for user configuration data you could use:

string configFolder;
if (!folderManager.TryGetConfigFolderPath(out configFolder)) 
{
    // configuration folder path could not be determined. 
    // logic to get out of that situation.
}
else
{
    // try to create user configuration folder: 
    if (!folderManager.TryCreateUserConfigFolder())
    {
        // user configuration folder could not be created. 
        // logic to get out of that situation. 
    }
}

Note: TryCreateUserDataFolder() and TryCreateUserConfigFolder() may throw InvalidOperationException if magic file validation is enabled and the expected magic file is not found. This indicates a serious configuration problem that should be handled at application level.

Now your strings dataFolder and configFolder are (hopefully) proper paths to where you want to store user data, sqlite file, json files etc and so on.

NuGet package

There is a NuGet package available for easy usage.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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.

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 112 3/22/2026 1.1.0 is deprecated.