MiJenner.ConfigUtils-FolderManager
0.9.0
dotnet add package MiJenner.ConfigUtils-FolderManager --version 0.9.0
NuGet\Install-Package MiJenner.ConfigUtils-FolderManager -Version 0.9.0
<PackageReference Include="MiJenner.ConfigUtils-FolderManager" Version="0.9.0" />
<PackageVersion Include="MiJenner.ConfigUtils-FolderManager" Version="0.9.0" />
<PackageReference Include="MiJenner.ConfigUtils-FolderManager" />
paket add MiJenner.ConfigUtils-FolderManager --version 0.9.0
#r "nuget: MiJenner.ConfigUtils-FolderManager, 0.9.0"
#:package MiJenner.ConfigUtils-FolderManager@0.9.0
#addin nuget:?package=MiJenner.ConfigUtils-FolderManager&version=0.9.0
#tool nuget:?package=MiJenner.ConfigUtils-FolderManager&version=0.9.0
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
Include the namespace:
using MiJenner.ConfigUtils;
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 four enums / locations (if username is john):
PolicyFileAppDataLocal: Windows C:\Users\john\AppData\Local, MacOS: /Users/john/.local/share, Linux: todoPolicyFileAppDataRoaming: Windows C:\Users\john\AppData\Roaming, MacOS: /Users/john/.config, Linux: todoPolicyFileDesktop: Windows C:\Users\john\Desktop, MacOS: /Users/john/Desktop, Linux: todoPolicyFileDocument: Windows C:\Users\john\Documents, MacOS: /Users/john/, Linux: todo
Note: the latter may not be possible due to security settings on Windows.
Next, you will typically create a folderManager instance, based on the just created configuration:
var folderManager = new DesktopFolderManager(config);
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 configuration 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(outconfigFolder))
{
// 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.
}
}
Now your strings cs dataFolder and cs configFolder are (hopefully) proper paths to where you want to store user data, sqlite file, json files etc and so on.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
-
net6.0
- MiJenner.FileUtils (>= 0.9.0)
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 |
|---|---|---|
| 0.9.0 | 228 | 9/9/2023 |