Univerzálny extraktor pre .NET
Úvod do Universal Extractor pre .NET
Univerzálny extraktor pre .NET je plugin, ktorý umožňuje vývojárom extrahovať archívy a komprimované súbory v rôznych formátoch, vrátane ZIP, RAR, 7Z, TAR, GZIP a ďalšie.
Podporované formáty archívov
Univerzálny extraktor pre .NET podporuje širokú škálu archívnych formátov, vrátane:
- Spoločnosť ZIP (ZIP)
- Zriedkavé ( .rar )
- 7 Z (7,7 Z)
- Zoznam ( .tar )
- Spoločnosť GZIP (.gz)
- BZIP2 (.bz2) v súvislosti s
extrakčné archívy
Ak chcete extrahovať archív pomocou Universal Extractor pre .NET, môžete použiť nasledujúci kódový príklad:
using System.IO;
using Aspose.Zip;
// Create a new instance of the Archive class
using (var archive = new Archive("example.zip"))
{
// Extract the archive to a directory
archive.ExtractToDirectory("extracted");
}
This code extracts the contents of the example.zip
archive to a directory named extracted
.
Odstrániť archívy s ochranou hesla
Ak je archív chránený heslom, môžete ho extrahovať pomocou nasledujúceho príkladu kódu:
using System.IO;
using Aspose.Zip;
// Create a new instance of the Archive class
using (var archive = new Archive("example.zip"), new ArchiveLoadOptions() { DecryptionPassword = "YOUR-PASSWORD" })
{
// Extract the archive to a directory
archive.ExtractToDirectory("extracted");
}
This code extracts the contents of the example.zip
archive, which is protected with a password, to a directory named extracted
.
Zoznam archívov obsah
Na zoznam obsahu archívu bez toho, aby ste ho vytiahli, môžete použiť nasledujúci príklad kódu:
using System.IO;
using Aspose.Zip;
// Create a new instance of the Archive class
using (var archive = new Archive("example.zip"))
{
// Get the entries in the archive
var entries = archive.Entries;
// Iterate over the entries and print their names
foreach (var entry in entries)
{
Console.WriteLine(entry.Name);
}
}
This code lists the contents of the example.zip
archive without extracting it.