DatStoreUtil 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package DatStoreUtil --version 1.0.0
                    
NuGet\Install-Package DatStoreUtil -Version 1.0.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="DatStoreUtil" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DatStoreUtil" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="DatStoreUtil" />
                    
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 DatStoreUtil --version 1.0.0
                    
#r "nuget: DatStoreUtil, 1.0.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 DatStoreUtil@1.0.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=DatStoreUtil&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=DatStoreUtil&version=1.0.0
                    
Install as a Cake Tool

DatStoreUtil

Biblioteca .NET 8 sin dependencias externas para guardar objetos en archivos .dat.

  • Serialización tipada mediante System.Text.Json.
  • Escritura atómica con archivo temporal.
  • Copia .bak automática al reemplazar datos.
  • Integridad SHA-256 para detectar modificaciones o daños.
  • Cifrado opcional AES-256-GCM con PBKDF2-SHA256.
  • Metadatos y errores tipados.

Un .dat no tiene un formato universal. Esta biblioteca abre los archivos .dat creados por ella; para un .dat de otro programa se necesita conocer su formato.

Instalación

dotnet add package DatStoreUtil --version 1.0.0

Uso básico

using DatStoreUtil;

var settings = new AppSettings("Mi equipo", true);
await DatFile.SaveAsync("configuracion.dat", settings);

AppSettings? loaded = await DatFile.LoadAsync<AppSettings>("configuracion.dat");

public sealed record AppSettings(string TeamName, bool NotificationsEnabled);

Al guardar por segunda vez, el valor anterior queda en configuracion.dat.bak y puede abrirse así:

AppSettings? previous = await DatFile.LoadBackupAsync<AppSettings>("configuracion.dat");

Cifrado

var secureOptions = new DatFileOptions
{
    Password = Environment.GetEnvironmentVariable("MI_DAT_PASSWORD")
        ?? throw new InvalidOperationException("Falta MI_DAT_PASSWORD")
};

await DatFile.SaveAsync("secretos.dat", settings, secureOptions);
AppSettings? secureData = await DatFile.LoadAsync<AppSettings>("secretos.dat", secureOptions);

No guardes contraseñas en el código ni en el repositorio. La contraseña debe tener al menos 12 caracteres al crear el archivo.

Abrir sin excepciones esperadas

DatFileReadResult<AppSettings> result =
    await DatFile.TryLoadAsync<AppSettings>("configuracion.dat");

if (result.IsSuccess)
{
    Console.WriteLine(result.Value?.TeamName);
}
else
{
    Console.WriteLine($"{result.ErrorCode}: {result.ErrorMessage}");
}

Utilidad incluida para abrir archivos DAT

El repositorio contiene samples/data/datos.dat. Para abrirlo:

dotnet run --project tools/DatStoreUtil.Cli -- samples/data/datos.dat

Compilar, probar y empaquetar

.\scripts\pack.ps1

El script deja el .nupkg y el paquete de símbolos .snupkg en artifacts/packages.

Antes de publicar una nueva versión, cambia <Version> en src/DatStoreUtil/DatStoreUtil.csproj. Para subirla a NuGet.org:

.\scripts\publish.ps1 -ApiKey $env:NUGET_API_KEY

El PackageId debe ser único en NuGet.org y la publicación requiere una cuenta con una API key.

Compatibilidad y límites

  • Requiere .NET 8 o posterior.
  • Formato actual: versión 1 (CDAT).
  • Tamaño máximo predeterminado: 64 MiB, configurable con MaxFileSizeBytes.
  • La escritura atómica y el bloqueo cubren procesos que usan correctamente esta biblioteca; no convierten el archivo en una base de datos multiusuario.

Licencia

MIT.

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.
  • net8.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.0.3 87 8/11/2026
1.0.2 88 8/11/2026
1.0.1 99 7/29/2026
1.0.0 98 7/28/2026

Primera versión: lectura y escritura tipada, integridad SHA-256, cifrado opcional, respaldo y metadatos.