ArchiveFlow 0.9.8
dotnet add package ArchiveFlow --version 0.9.8
NuGet\Install-Package ArchiveFlow -Version 0.9.8
<PackageReference Include="ArchiveFlow" Version="0.9.8" />
paket add ArchiveFlow --version 0.9.8
#r "nuget: ArchiveFlow, 0.9.8"
// Install ArchiveFlow as a Cake Addin #addin nuget:?package=ArchiveFlow&version=0.9.8 // Install ArchiveFlow as a Cake Tool #tool nuget:?package=ArchiveFlow&version=0.9.8
ArchiveFlow
ArchiveFlow is a Fluent API for streamlined and efficient processing of zipped and unzipped file archives. It lets you focus on processing logic instead of file/zip handling code.
Features
- Fluent interface for easy configuration and usage.
- Support for both zipped and unzipped file processing.
- Supports .zip, .7z, and .rar archives
- Customizable file filtering based on extensions and custom predicates.
- Options for reading files as text, binary, or streams.
- Parallel processing capabilities with configurable degrees of parallelism.
- Extensible design for future enhancements.
- Exception handling for robust processing.
- Support for a wide range of frameworks
Getting Started
Installation
To use ArchiveFlow in your project, add the following package to your dependencies:
dotnet add package ArchiveFlow
Usage
Basic Example
Here's a a simple example to get you started with ArchiveFlow. This will process all files as text file in archive files in the specified folder. The default behaviour is to process all entries in archive files in the folder (non-recursive), and ignore non archive files.
var builder = new FileProcessorBuilder()
.FromFolder("./your/path")
.ProcessAsText((f, t) =>
{
// Your text processing logic here
})
builder.Build().ProcessFiles();
More Advanced Example
Here's an example that is a bit more advanced. It reads all xml files in the specified folder, recursively, including archives younger than 10 days, and processes the text as xml. It also sets the maximum degree of parallelism to the number of processors on the machine, and handles exceptions for corrupted zip files.
// use a concurrent dictionary beacuse we are using multiple threads
var dict = new ConcurrentDictionary<string, byte>();
var builder = new FileProcessorBuilder()
.FromFolder("/folder/with/xmlfiles_archived_or_not", FolderSelect.RootAndSubFolders)
.SetArchiveSearch(ArchiveSearch.SearchInAndOutsideArchives)
.FromZipWhere((z) => z.LastModified > DateTime.Now.AddDays(-10))
.WhereFile((f) => !f.FileName.Contains("ReturnValue"))
.ProcessAsText((f, t) =>
{
XDocument xdoc = XDocument.Parse(t);
(string? id, string? name) =
(xdoc.Descendants("Id").FirstOrDefault()?.Value,
xdoc.Descendants("Name").FirstOrDefault()?.Value);
dict.TryAdd($"{id}_{name}", 0);
})
.WithMaxDegreeOfParallelism(Environment.ProcessorCount)
.HandleExceptionWith((f, ex) =>
{
if (f.Extension == ".zip" && ex is InvalidOperationException)
{
// ignore these exceptions for zip files (corrupted zip)
return true;
}
return false;
});
builder.Build().ProcessFiles();
check out this fiddle for a working example: https://dotnetfiddle.net/sIwHrW
Contributing
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License
Distributed under the MIT License.
Contact
Dominique Biesmans - https://www.linkedin.com/in/dominiquebiesmans/
Project Link: https://github.com/domibies/archive-flow
Product | Versions 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 is compatible. |
.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. |
-
.NETStandard 2.0
- SharpCompress (>= 0.34.2)
-
.NETStandard 2.1
- SharpCompress (>= 0.34.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.