com.spoiledcat.simpleio.runtime 2.2.17

dotnet add package com.spoiledcat.simpleio.runtime --version 2.2.17                
NuGet\Install-Package com.spoiledcat.simpleio.runtime -Version 2.2.17                
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="com.spoiledcat.simpleio.runtime" Version="2.2.17" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add com.spoiledcat.simpleio.runtime --version 2.2.17                
#r "nuget: com.spoiledcat.simpleio.runtime, 2.2.17"                
#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 com.spoiledcat.simpleio.runtime as a Cake Addin
#addin nuget:?package=com.spoiledcat.simpleio.runtime&version=2.2.17

// Install com.spoiledcat.simpleio.runtime as a Cake Tool
#tool nuget:?package=com.spoiledcat.simpleio.runtime&version=2.2.17                

SimpleIO

Fork of NiceIO with major changes to the original, hence the name change. Changes include:

  • Path representation is now a struct - class NPathstruct SPath
  • All filesystem operations go through a IFileSystem abstraction, with a default implementation using the System.IO API. The filesystem implementation can be switched out at compile time or runtime.
  • File and directory operations that required absolute paths (due to underlying System.IO API restrictions) now support relative paths, which are internally resolved to absolute paths using the value returned by CurrentDirectory.
  • The Editor and Runtime classes are the same, except that the Editor implementation uses Mono.Posix in order to resolve filesystem paths.
  • File read/write methods added - Read/WriteAllBytes, OpenRead/Write
  • System information properties added: HomeDirectory, LocalAppData, CommonAppData, SystemTemp
  • More OS detection added - IsWindows, IsLinux, IsMac

Basic usage:

//paths are immutable
SPath path1 = new SPath(@"/var/folders/something");
// /var/folders/something

//use back,forward,or trailing slashes,  doesnt matter
SPath path2 = new SPath(@"/var\folders/something///");
// /var/folders/something

//semantically the same
path1 == path2;
// true

// ..'s that are not at the beginning of the path get collapsed
new SPath("/mydir/../myfile.exe");
// /myfile.exe

//build paths
path1.Combine("dir1/dir2");
// /var/folders/something/dir1/dir2

//handy accessors
SPath.HomeDirectory;
// /Users/lucas

//all operations return their destination, so they fluently daisychain
SPath myfile = SPath.HomeDirectory.CreateDirectory("mysubdir").CreateFile("myfile.txt");
// /Users/lucas/mysubdir/myfile.txt

//common operations you know and expect
myfile.Exists();
// true

//you will never again have to look up if .Extension includes the dot or not
myfile.ExtensionWithDot;
// ".txt"

//getting parent directory
SPath dir = myfile.Parent;
// /User/lucas/mysubdir

//copying files,
myfile.Copy("myfile2");
// /Users/lucas/mysubdir/myfile2

//into not-yet-existing directories
myfile.Copy("hello/myfile3");
// /Users/lucas/mysubdir/hello/myfile3

//listing files
dir.Files(recurse:true);
// { /Users/lucas/mysubdir/myfile.txt, 
//   /Users/lucas/mysubdir/myfile2, 
//   /Users/lucas/mysubdir/hello/myfile3 }

//or directories
dir.Directories();
// { /Users/lucas/mysubdir/hello }

//or both
dir.Contents(recurse:true);
// { /Users/lucas/mysubdir/myfile.txt, 
//   /Users/lucas/mysubdir/myfile2, 
//   /Users/lucas/mysubdir/hello/myfile3, 
//   /Users/lucas/mysubdir/hello }

//copy entire directory, and listing everything in the copy
myfile.Parent.Copy("anotherdir").Files(recurse:true);
// { /Users/lucas/anotherdir/myfile, 
//   /Users/lucas/anotherdir/myfile.txt, 
//   /Users/lucas/anotherdir/myfile2, 
//   /Users/lucas/anotherdir/hello/myfile3 }

//easy accesors for common operations:
string text = myfile.ReadAllText();
string[] lines = myfile.ReadAllLines();
myFile.WriteAllText("hello");
myFile.WriteAllLines(new[] { "one", "two"});

SimpleIO is MIT Licensed.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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. 
.NET Core netcoreapp3.1 is compatible. 
.NET Framework net471 is compatible.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 3.1

    • No dependencies.
  • .NETFramework 4.7.1

    • 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
2.2.17 112 12/12/2024
2.2.14 97 10/22/2024
2.2.3 485 10/10/2022
2.2.1 468 9/27/2022
2.2.0 375 8/23/2022