ByteDev.Io 7.0.0

Set of IO related .NET utility classes.

Install-Package ByteDev.Io -Version 7.0.0
dotnet add package ByteDev.Io --version 7.0.0
<PackageReference Include="ByteDev.Io" Version="7.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ByteDev.Io --version 7.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

ByteDev.Io

Set of IO related .NET utility classes.

Installation

ByteDev.Io has been written as a .NET Standard 2.0 library, so you can consume it from a .NET Core or .NET Framework 4.6.1 (or greater) application.

ByteDev.Io is hosted as a package on nuget.org. To install from the Package Manager Console in Visual Studio run:

Install-Package ByteDev.Io

Further details can be found on the nuget page.

Release Notes

Releases follow semantic versioning.

Full details of the release notes can be viewed on GitHub.

Usage

To use these main public classes simply reference ByteDev.Io.

FileSytem

Provides a small set of methods for working with files and directories.

Methods:

  • IsFile
  • IsDirectory
  • FirstExists
  • MoveFile
  • CopyFile
  • SwapFileNames
// Initialize object
IFileSystem fs = new FileSystem();
// Is it a file? Is it a directory?

bool isFile = fs.IsFile(@"C:\Temp\Something");
bool isDir = fs.IsDirectory(@"C:\Temp\Something");
// Return first thing that exists

string[] paths =
{
    @"C:\Temp\Test1.txt",
    @"C:\Temp\Test2.txt",
    @"C:\Temp\TestDirectory",
};

var path = fs.FirstExists(paths);
// Move a file

string sourceFile = @"C:\Temp\TestFile1.txt";
string destinationFile = @"C:\Windows\TestFile1.txt";

FileInfo info = fs.MoveFile(sourceFile, destinationFile, 
    FileOperationBehaviourType.DestExistsOverwrite);

// info.FullName = @"C:\Windows\TestFile1.txt" if successful
// Copy a file

string sourceFile = @"C:\Temp\TestFile1.txt";
string destinationFile = @"C:\Windows\TestFile1.txt";

FileInfo info = fs.CopyFile(sourceFile, destinationFile, 
    FileOperationBehaviourType.DestExistsOverwrite);

// info.FullName = @"C:\Windows\TestFile1.txt" if successful
// Swap two existing file's names

string file1 = @"C:\Temp\archive1.png";
string file2 = @"C:\Temp\cover.png";

fs.SwapFileNames(file1, file2);

FileSize

Represents file size.

long numberOfBytes = 1048576;

FileSize fileSize = new FileSize(numberOfBytes, FileSize.MultiplierType.DecimalMultiplier);

Console.Write(fileSize.ReadableSize);           // "1 MB"
Console.Write(fileSize.TotalBytes);             // 1048576
Console.Write(fileSize.TotalKiloBytes);         // 1048
Console.Write(fileSize.TotalMegaBytes);         // 1

FileComparer

Provides functionality to compare two files.

Methods:

  • IsSourceBigger
  • IsSourceBiggerOrEqual
  • IsSourceModifiedMoreRecently

IsolatedStorageIo

Provides functionality for isolated storage operations. To use reference namespace: ByteDev.Io.IsolatedStorage.

Methods:

  • Exists
  • Delete
  • Write
  • Read
  • ReadAsXmlDoc
  • ReadAsXDoc
var io = new IsolatedStorageIo(IsolatedStorageFileType.UserStoreForApplication);

var fileName = new IsolatedStorageFileName("MyIsolatedFile", new Version(1, 0), ".txt");

io.Write(fileName, "Some data");

bool exists = io.Exists(fileName);

string data = io.Read(fileName);

io.Delete(fileName);

StreamFactory

Provides simple functionality to create memory streams.

MemoryStream stream = StreamFactory.Create("some text");

DirectoryInfoExtensions

  • CreateDirectory
  • DeleteIfExists
  • DeleteIfEmpty
  • DeleteDirectories
  • DeleteDirectoriesWithName
  • DeleteEmptyDirectories
  • DeleteFiles
  • DeleteFilesExcept
  • Empty
  • EmptyIfExists
  • GetFilesByExtensions
  • GetAudioFiles
  • GetImageFiles
  • GetVideoFiles
  • GetSize
  • IsEmpty

FileInfoExtensions

  • AddExtension
  • DeleteIfExists
  • DeleteLine
  • DeleteLines
  • GetExtension
  • GetNextAvailableFileName
  • HasExtension
  • IsBinary
  • RenameExtension
  • RemoveExtension
  • ReplaceLine
  • ReplaceLines

StreamExtensions

  • IsEmpty
  • ReadAsBytes
  • ReadAsMemoryStream
  • ReadAsString
  • WriteToFile
  • WriteToFileAsync

StreamReaderExtensions

  • ReadLineKeepNewLineChars

ByteDev.Io

Set of IO related .NET utility classes.

Installation

ByteDev.Io has been written as a .NET Standard 2.0 library, so you can consume it from a .NET Core or .NET Framework 4.6.1 (or greater) application.

ByteDev.Io is hosted as a package on nuget.org. To install from the Package Manager Console in Visual Studio run:

Install-Package ByteDev.Io

Further details can be found on the nuget page.

Release Notes

Releases follow semantic versioning.

Full details of the release notes can be viewed on GitHub.

Usage

To use these main public classes simply reference ByteDev.Io.

FileSytem

Provides a small set of methods for working with files and directories.

Methods:

  • IsFile
  • IsDirectory
  • FirstExists
  • MoveFile
  • CopyFile
  • SwapFileNames
// Initialize object
IFileSystem fs = new FileSystem();
// Is it a file? Is it a directory?

bool isFile = fs.IsFile(@"C:\Temp\Something");
bool isDir = fs.IsDirectory(@"C:\Temp\Something");
// Return first thing that exists

string[] paths =
{
    @"C:\Temp\Test1.txt",
    @"C:\Temp\Test2.txt",
    @"C:\Temp\TestDirectory",
};

var path = fs.FirstExists(paths);
// Move a file

string sourceFile = @"C:\Temp\TestFile1.txt";
string destinationFile = @"C:\Windows\TestFile1.txt";

FileInfo info = fs.MoveFile(sourceFile, destinationFile, 
    FileOperationBehaviourType.DestExistsOverwrite);

// info.FullName = @"C:\Windows\TestFile1.txt" if successful
// Copy a file

string sourceFile = @"C:\Temp\TestFile1.txt";
string destinationFile = @"C:\Windows\TestFile1.txt";

FileInfo info = fs.CopyFile(sourceFile, destinationFile, 
    FileOperationBehaviourType.DestExistsOverwrite);

// info.FullName = @"C:\Windows\TestFile1.txt" if successful
// Swap two existing file's names

string file1 = @"C:\Temp\archive1.png";
string file2 = @"C:\Temp\cover.png";

fs.SwapFileNames(file1, file2);

FileSize

Represents file size.

long numberOfBytes = 1048576;

FileSize fileSize = new FileSize(numberOfBytes, FileSize.MultiplierType.DecimalMultiplier);

Console.Write(fileSize.ReadableSize);           // "1 MB"
Console.Write(fileSize.TotalBytes);             // 1048576
Console.Write(fileSize.TotalKiloBytes);         // 1048
Console.Write(fileSize.TotalMegaBytes);         // 1

FileComparer

Provides functionality to compare two files.

Methods:

  • IsSourceBigger
  • IsSourceBiggerOrEqual
  • IsSourceModifiedMoreRecently

IsolatedStorageIo

Provides functionality for isolated storage operations. To use reference namespace: ByteDev.Io.IsolatedStorage.

Methods:

  • Exists
  • Delete
  • Write
  • Read
  • ReadAsXmlDoc
  • ReadAsXDoc
var io = new IsolatedStorageIo(IsolatedStorageFileType.UserStoreForApplication);

var fileName = new IsolatedStorageFileName("MyIsolatedFile", new Version(1, 0), ".txt");

io.Write(fileName, "Some data");

bool exists = io.Exists(fileName);

string data = io.Read(fileName);

io.Delete(fileName);

StreamFactory

Provides simple functionality to create memory streams.

MemoryStream stream = StreamFactory.Create("some text");

DirectoryInfoExtensions

  • CreateDirectory
  • DeleteIfExists
  • DeleteIfEmpty
  • DeleteDirectories
  • DeleteDirectoriesWithName
  • DeleteEmptyDirectories
  • DeleteFiles
  • DeleteFilesExcept
  • Empty
  • EmptyIfExists
  • GetFilesByExtensions
  • GetAudioFiles
  • GetImageFiles
  • GetVideoFiles
  • GetSize
  • IsEmpty

FileInfoExtensions

  • AddExtension
  • DeleteIfExists
  • DeleteLine
  • DeleteLines
  • GetExtension
  • GetNextAvailableFileName
  • HasExtension
  • IsBinary
  • RenameExtension
  • RemoveExtension
  • ReplaceLine
  • ReplaceLines

StreamExtensions

  • IsEmpty
  • ReadAsBytes
  • ReadAsMemoryStream
  • ReadAsString
  • WriteToFile
  • WriteToFileAsync

StreamReaderExtensions

  • ReadLineKeepNewLineChars

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ByteDev.Io:

Package Downloads
ByteDev.Testing
.NET Standard library that provides some testing related functionality.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
7.0.0 38 9/30/2020
6.0.0 101 9/24/2020
5.0.0 161 4/12/2020
4.0.0 128 11/29/2019
3.2.1 242 1/19/2019
3.2.0 252 1/19/2019
3.1.0 280 10/1/2018
3.0.0 257 9/19/2018
2.0.0 372 5/22/2018