TagBites.IO
Lightweight and simple .NET library provides facilities for performing operations on file systems.
TagBites.IO provides implementation for many built-ins file systems:
and also allows you to create your custom file system.
NuGet Package: https://www.nuget.org/packages/TagBites.IO/
Examples
Checking if a file exists.
var exists = FileSystem.Local.GetFile("file.txt").Exists;
Read all text from a file.
var content = FileSystem.Local.GetFile("file.txt").ReadAllText();
Asynchronously write the text to a file.
await FileSystem.Local.GetFile("file.txt").WriteAllTextAsync("test content");
Rename the file.
FileSystem.Local.GetFile("file.txt").Rename("newTest");
Move and overwrite the file.
var source = FileSystem.Local.GetFile("a/test2.txt");
var destination = FileSystem.Local.GetFile("b/test2.txt");
source.Move(destination, true);
Move the directory to a new location.
var source = FileSystem.Local.GetDirectory("a/c");
var destination = FileSystem.Local.GetDirectory("b");
source.MoveTo(destination); // b/c/*
Restore a copy of the file.
var file = FileSystemWithHistorySupport.Create().GetFile("file.txt");
var fileVersion = file.GetHistoryVersions(DateTime.Now.Date.AddDays(-7)).FirstOrDefault();
fileVersion.Copy(file, true) ;
Synchronization of directory contents between file systems.
var ftpFileSystem = FtpFilesystem.Create(/*parameters*/);
var localFileSystem = FileSystem.Local;
var directory1 = localFileSystem.GetDirectory("directory1");
var directory2 = localFileSystem.GetDirectory("directory2");
directory1.SyncWith(directory2, FileSystemSynchronizeMode.OneWay);