SimpleFileIO 0.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package SimpleFileIO --version 0.0.3                
NuGet\Install-Package SimpleFileIO -Version 0.0.3                
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="SimpleFileIO" Version="0.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SimpleFileIO --version 0.0.3                
#r "nuget: SimpleFileIO, 0.0.3"                
#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.
// Install SimpleFileIO as a Cake Addin
#addin nuget:?package=SimpleFileIO&version=0.0.3

// Install SimpleFileIO as a Cake Tool
#tool nuget:?package=SimpleFileIO&version=0.0.3                

SimpleFileIO

Summary

SimpleFileIO is a library designed to provide a unified interface for record-based IO management. It supports the following file types and features:

  • CSV: Structured data storage in CSV format.
  • Appendable CSV (Log): Incremental logging directly into a CSV file.
  • Text: General text file management.
  • Appendable Text (Log): Incremental logging into plain text files.

This library eliminates unnecessary dependencies while maintaining flexibility and ease of use. CsvHelper is used for advanced CSV management.

Key Features

  • Unified interface for multiple file types (CSV, Text, Logs).
  • Modular approach.

How to

Text Log

using SimpleFileIO;
using SimpleFileIO.Utility;
using SimpleFileIO.Log.Text;

// Create Intance
PathProperty pathProperty =new PathProperty() {
    RootDirectory = new DirectoryInfo("./Test"),
    FileName="TestTextLog",
    Extension="txtlog" };
ITextLog? returnItem = Manager.CreateTextLog("TestTextLog", pathProperty);
// Get Intance
ITextLog? getItem = Manager.GetTextLog("TestTextLog") ?? null;
// Check Invaild Intance
if (getItem is null)
    throw new Exception("not create text log.");
// Add log contents
getItem.Add("aaa");
getItem.Add("bbb");
// Write
getItem.Write();

CSV Log

using CsvHelper;
using SimpleFileIO;
using SimpleFileIO.Utility;
using SimpleFileIO.Log.Csv;

// Create Intance
PathProperty pathProperty =new PathProperty() {
    RootDirectory = new DirectoryInfo("./Test"),
    FileName="TestCSVLog",
    Extension="csvlog" };
ICSVLog? returnItem = Manager.CreateCsvLog("TestCSVLog", pathProperty);
// Get Intance
ICSVLog? getItem = Manager.GetCsvLog("TestCSVLog") ?? null;
// Check Invaild Intance
if (getItem is null)
    throw new Exception("not create text log.");
// Create log Item
var data1 = new testdata();
data1.int1 = 01;
var data2 = new testdata();
data1.int2 = 02;

// Add log contents
getItem.Add(data1);
getItem.Add(data2);
// Write
getItem.Write();
using CsvHelper.Configuration;
using CsvHelper.TypeConversion;
using CsvHelper;
using CsvHelper.Configuration.Attributes;

namespace YourNamespace
{
    internal class testdata
    {
        [Name("Int1")]
        public int int1 { get; set; } = 21;
        [Name("Int2")]
        public int int2 { get; set; } = 22;
        [Name("Int3")]
        public int int3 { get; set; } = 23;
        [Name("Flaot1")]
        public float flaot1 { get; set; } = 25.5f;
        [Name("Flaot2")]
        public float flaot2 { get; set; } = 26.6f;
        [Name("Flaot3")]
        public float flaot3 { get; set; } = 27.7f;
        [Name("String1")]
        [CsvHelper.Configuration.Attributes.TypeConverter(typeof(StringArrayConverter))]
        public string[] string1 { get; set; } = { "2S,9", "43424", "23443" };
        [Name("String2")]
        public string string2 { get; set; } = "2S,10";
        [Name("String3")]
        public string string3 { get; set; } = "2S,11";
    }
}

//Use Custom
public class StringArrayConverter : ITypeConverter
{
    public string? ConvertToString(object? value, IWriterRow row, MemberMapData memberMapData)
    {
        if (value == null)
        {
            return string.Empty;
        }
        // to linearization, separator character ';'
        return string.Join(";", (string[])value);
    }

    public object? ConvertFromString(string? text, IReaderRow row, MemberMapData memberMapData)
    {
        if (string.IsNullOrEmpty(text))
        {
            return Array.Empty<string>();
        }
        // to array, separator character ';'
        return text.Split(';');
    }
}

INI State Save

using SimpleFileIO;
using SimpleFileIO.Utility;
using SimpleFileIO.State.Ini;

// Create Intance
Manager.CreateIniState("TestIni", new() { RootDirectory = new("./Test"), FileName = "TestIni", Extension = ".ini" });
// Get Intance
IINIState? iniState = Manager.GetIniState("TestIni") ?? null;
// Check Invaild Intance
if (iniState is null)
    throw new Exception("not create ini.");
// Load
iniState.Load();
// Edit item contents [Section][Key][Value]
iniState.SetValue("MY", "ITEM1", "111");
iniState.SetValue("MY", "ITEM2", "222");
iniState.SetValue("YOUR", "CAR1", "333");
iniState.SetValue("YOUR", "CAR2", "444");
//Edit item content (using parser) [Section][Key][(type)Value]
iniState.SetValue_UseParser<byte>("Parser", "byte", (byte)1);
iniState.SetValue_UseParser<sbyte>("Parser", "sbyte", (sbyte)2);
iniState.SetValue_UseParser<short>("Parser", "short", (short)3);
iniState.SetValue_UseParser<ushort>("Parser", "ushort", (ushort)4);
iniState.SetValue_UseParser<int>("Parser", "int", (int)5);
iniState.SetValue_UseParser<uint>("Parser", "uint", (uint)6);
iniState.SetValue_UseParser<long>("Parser", "long", (long)7);
iniState.SetValue_UseParser<ulong>("Parser", "ulong", (ulong)8);
iniState.SetValue_UseParser<float>("Parser", "float", (float)9.9f);
iniState.SetValue_UseParser<double>("Parser", "double", (double)10.10);
iniState.SetValue_UseParser<decimal>("Parser", "decimal", (decimal)11.11);
iniState.SetValue_UseParser<char>("Parser", "char", (char)'a');
iniState.SetValue_UseParser<string>("Parser", "string", (string)"b");
iniState.SetValue_UseParser<bool>("Parser", "bool", (bool)true);
iniState.SetValue_UseParser<string[]>("Parser", "string array", new[] { "c", "d", "e", "f" });
iniState.SetValue_UseParser<PathProperty>("Parser", "path property",
    new PathProperty{ RootDirectory = new DirectoryInfo("./GGGG"), FileName = "HHHH", Extension = "IIII" });

INI State Load

using SimpleFileIO;
using SimpleFileIO.Utility;
using SimpleFileIO.State.Ini;
/////////////////////////////////////////////////
// New load and check datas
IINIState? findINI = Manager.CreateIniState("TestFindIni",
    new() { RootDirectory = new("./Test"), FileName = "TestIni", Extension = ".ini" });
if (findINI is null)
    throw new Exception("not create ini.");
findINI.ThrowExceptionMode = true;
// load
findINI.Load();
// Get Value [Section][Key][Default]
findINI.GetValue("MY", "ITEM1", "111");
findINI.GetValue("MY", "ITEM2", "222");
findINI.GetValue("YOUR", "CAR1", "333");
findINI.GetValue("YOUR", "CAR2", "444");
// Get Value (using parser) [Section][Key][(type)Default]
var getByte = findINI.GetValue_UseParser<byte>("Parser", "byte", (byte)0);
var getSbyte = findINI.GetValue_UseParser<sbyte>("Parser", "sbyte", (sbyte)0);
var getShort = findINI.GetValue_UseParser<short>("Parser", "short", (short)0);
var getUshort = findINI.GetValue_UseParser<ushort>("Parser", "ushort", (ushort)0);
var getInt = findINI.GetValue_UseParser<int>("Parser", "int", (int)0);
var getUint = findINI.GetValue_UseParser<uint>("Parser", "uint", (uint)0);
var getLong = findINI.GetValue_UseParser<long>("Parser", "long", (long)0);
var getUlong = findINI.GetValue_UseParser<ulong>("Parser", "ulong", (ulong)0);
var getFloat = findINI.GetValue_UseParser<float>("Parser", "float", (float)0.0f);
var getDouble = findINI.GetValue_UseParser<double>("Parser", "double", (double)0.0);
var getDecimal = findINI.GetValue_UseParser<decimal>("Parser", "decimal", (decimal)0.0);
var getChar = findINI.GetValue_UseParser<char>("Parser", "char", (char)'x');
var getString = findINI.GetValue_UseParser<string>("Parser", "string", (string)"x");
var getBool = findINI.GetValue_UseParser<bool>("Parser", "bool", (bool)true);
var getStringArray = findINI.GetValue_UseParser<string[]>("Parser", "string array", new[] { "x", "x", "x", "x" });
var getPathProperty = findINI.GetValue_UseParser<PathProperty>("Parser", "path property",
    new PathProperty { RootDirectory = new DirectoryInfo("./XXXX"), FileName = "XXXX", Extension = "XXXX" });

INI State Add Parser

// add parser
IINIState? parserINI = Manager.CreateIniState("TestparserIni",
    new() { RootDirectory = new("./Test"), FileName = "TestIni", Extension = ".ini" });
if (parserINI is null)
    throw new Exception("not create ini.");
parserINI.ThrowExceptionMode = true;

var stringTypeParser = new StringTypeParser() {
    TargetType = typeof(parserTpye1),
    ObjectToString = (obj) =>
    {
        if (obj is parserTpye1 item)
            return $"{item.Name},{item.Index}";
        return null;
    },
    StringToObject = (str) =>
    {
        var result = new parserTpye1();
        var strArray = str.Split(',');
        if (strArray.Count() is 2)
        {
            result.Name = strArray[0];
            result.Index = Int32.Parse(strArray[1]);
        }
        return result;
    },
};
parserINI.AddParser(typeof(parserTpye1), stringTypeParser);

var tempItem = new parserTpye1() { Name = "MYNAME", Index = 10 };
parserINI.SetValue_UseParser<parserTpye1>("Add Parser", "Parser Tpye1", tempItem);
var getItem = parserINI.GetValue_UseParser<parserTpye1>("Add Parser", "Parser Tpye1", tempItem);
internal class parserTpye1
{
    internal string Name { get; set; } = "";
    internal int Index { get; set; } = -1;
}

Notes

Third-Party Libraries

CsvHelper

  • Version: 33.0.1
  • License: Apache-2.0 OR MS-PL
  • Copyright: © 2009–2024 Josh Close
  • Project URL: CsvHelper Project
  • Nuget: CsvHelper NuGet
  • Usage:
    • Used for advanced CSV parsing and serialization.

SimpleComposeActions

  • Version: N/A
  • License: MIT
  • Copyright: © 2024–2025 Natel210
  • Project URL: SimpleComposeActions
  • Usage:
    • Used as a modular and reusable GitHub Actions workflow template.
    • Facilitates simplified CI/CD pipeline setup by enabling developers to compose workflows using pre-defined modular actions.
    • Provides pre-tested components to improve productivity and reduce workflow errors.
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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on SimpleFileIO:

Package Downloads
SimpleOverlayTheme

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.4 83 2/26/2025
0.1.3 62 2/26/2025
0.1.1 72 2/26/2025
0.0.12 64 2/26/2025
0.0.11 60 2/26/2025
0.0.10 70 2/26/2025
0.0.9 68 2/26/2025
0.0.8 71 2/24/2025
0.0.7 60 2/24/2025
0.0.6 81 2/11/2025
0.0.5 68 2/11/2025
0.0.4 79 2/11/2025
0.0.3 86 2/5/2025