DotNetHelper-IO is a simple easy to use thread safe library for handling all types of files & folders
|| Documentation • API • Tutorials || Change Log • || View on Github||
Package | Tests | Code Coverage |
---|---|---|
Continous Integration | Windows | Linux | MacOS |
---|---|---|---|
AppVeyor | |||
Azure Devops |
+ Auto Increment File Name
+ Auto Increment File Extension
+ Writing with async support
+ Reading with async support
+ Get file/folder file sizes by any size unit, example , bytes,kb,mb,gb etc..
+ Archive file support (.zip .rar .tar .7z .gzip)
var file = new FileObject($@"C:\Temp\MyTestFile.txt");
file.Write("Will create MyTestFile.txt with this content", FileOption.Append);
file.Write("will ovewrite the file MyTestFile.txt with this text", FileOption.Overwrite);
file.Write("nothing will happen since file already exist", FileOption.DoNothingIfExist);
var newFileName = file.Write("will create file MyTestFile.txt1 and this method returns file name", FileOption.IncrementFileExtensionIfExist);
var newFileName2 = file.Write("will create file MyTestFile1.txt and this method returns file name ", FileOption.IncrementFileNameIfExist);
var file = new FileObject($@"C:\Temp\MyTestFile.txt");
// Copies & Append file content to specified path
file.CopyTo("D:\\Temp\\MyTestFile.txt", FileOption.Append);
// Copies file content and paste it to specified path and will overwrite if other file already exist
file.CopyTo("D:\\Temp\\MyTestFile.txt", FileOption.Overwrite);
// Copies file content to specified path only if it doesn't exist otherwise do nothing
file.CopyTo("D:\\Temp\\MyTestFile.txt", FileOption.DoNothingIfExist);
// Copy file content to specified path. If path already exist then create a new file with the file extension increment.
var newFileName = file.CopyTo("D:\\Temp\\MyTestFile.txt", FileOption.IncrementFileExtensionIfExist);
// Copy file content to specified path. If path already exist then create a new file with the file name increment.
var newFileName2 = file.CopyTo("D:\\Temp\\MyTestFile.txt", FileOption.IncrementFileNameIfExist);
var zipFile = new ZipFileObject($"C:\\Temp\\test.zip",ArchiveType.Zip);
using (var archive = zipFile.GetReadableArchive())
{
foreach (var entry in archive.Entries)
{
var fileNameInZip = entry.Key;
var fileContent = entry.OpenEntryStream();
}
}
var zipFileObj = new ZipFileObject($"C:\\Temp\\test.zip", ArchiveType.Zip);
// overwrite file in zip if it already exist
zipFileObj.Add($"C:\\Temp\\TestFile.txt",FileOption.Overwrite);
// don't add to zip if already exist
zipFileObj.Add($"C:\\Temp\\TestFile.txt", FileOption.DoNothingIfExist);
// append to the same file in zip
zipFileObj.Add($"C:\\Temp\\TestFile.txt", FileOption.Append);
For more information, please refer to the Officials Docs