OkTools.NiceIO 1.0.3

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

// Install OkTools.NiceIO as a Cake Tool
#tool nuget:?package=OkTools.NiceIO&version=1.0.3                

NiceIO

build and
test

For when you've had to use System.IO one time too many.

I need to make c# juggle files & directories around a lot. It has to work on osx, linux and windows. It always hurts, and I've never enjoyed it. NiceIO is an attempt to fix that. It's a single file library, no binaries, no .csproj's, no nuget specs, or any of that. .NET Framework 3.5. Whenever dealing with files makes you cringe, just grab NiceIO.cs, throw it in your project and get on with your business.

This project is in a very early state and the API is very far from stable.

Basic usage:

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

//use back,forward,or trailing slashes,  doesnt matter
NPath path2 = new NPath(@"/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 NPath("/mydir/../myfile.exe");
// /myfile.exe

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

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

//all operations return their destination, so they fluently daisychain
NPath myfile = NPath.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
NPath 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"});

NiceIO 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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on OkTools.NiceIO:

Package Downloads
OkTools.Core

These tools are ok.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.10 165 11/15/2024
1.0.9 141 9/27/2024
1.0.8 109 9/26/2024
1.0.7 337 9/14/2024
1.0.6 487 2/18/2024
1.0.5 278 1/4/2024
1.0.4 182 12/24/2023
1.0.3 247 12/19/2023
1.0.2 283 11/21/2023
1.0.1 193 11/16/2023
1.0.0 186 11/16/2023