# Pierwsze kroki z IronZIP
## IronZIP: Twoja uniwersalna biblioteka archiwów dla .NET
**IronZIP** jest biblioteką do kompresji i dekompresji archiwów opracowaną przez Iron Software. Oprócz powszechnie używanego formatu ZIP obsługuje również formaty TAR, GZIP i BZIP2.
### C# Biblioteka do kompresji i dekompresji archiwów
1. [Pobierz bibliotekę C# do kompresji i dekompresji plików](https://www.nuget.org/packages/IronZip/)
2. Obsługa formatów ZIP, TAR, GZIP i BZIP2
3. Dostosowanie poziomów kompresji od 0 do 9
4. Wyodrębnianie zawartości z archiwów skompresowanych
5. Dodawanie plików do istniejących archiwów ZIP i generowanie nowych plików ZIP
### Kompatybilność
**IronZIP** oferuje kompatybilność międzyplatformową z:
#### Wsparcie wersji .NET:
- **C#**, **VB.NET**, **F#**
- **.NET 7, 6**, 5 i Core 3.1+
- .NET Standard (2.0+)
- .NET Framework (4.6.2+)
#### Wsparcie dla systemów operacyjnych i środowisk:
- **Windows** (10+, Server 2016+)
- **Linux** (Ubuntu, Debian, CentOS, itd.)
- **macOS** (10+)
- **iOS** (12+)
- **Android** API 21+ (v5 "Lollipop")
- **Docker** (Windows, Linux, Azure)
- **Azure** (VPS, WebApp, Function)
- **AWS** (EC2, Lambda)
#### Wsparcie dla typów projektów .NET:
- **Web** (Blazor i WebForms)
- **Mobile** (Xamarin i MAUI)
- **Desktop** (WPF i MAUI)
- **Konsolowe** (Aplikacja & Biblioteka)
## Instalacja
### Biblioteka IronZIP
Aby zainstalować pakiet IronZIP, użyj następującej komendy w terminalu lub konsoli menedżera pakietów:
```shell
:ProductInstall
```
Alternatywnie, pobierz bezpośrednio ze [strony oficjalnej IronZIP na NuGet](https://www.nuget.org/packages/IronZip).
Po zainstalowaniu możesz rozpocząć, dodając `using IronZip;` na początku kodu C#.
## Stosowanie klucza licencyjnego
Następnie, zastosuj ważną licencję lub klucz próbny do IronZIP, przypisując klucz licencyjny do właściwości LicenseKey klasy License. Załącz następujący kod zaraz po instrukcji importu, przed użyciem jakichkolwiek metod IronZIP:
```csharp
using IronZip;
// Apply your license key here
IronZip.License.LicenseKey = "YOUR_LICENSE_KEY";
```
## Przykłady kodu
### Przykład tworzenia archiwum
Utwórz plik ZIP za pomocą instrukcji `using`. W bloku using, użyj metody `AddArchiveEntry`, aby zaimportować pliki do pliku ZIP. Na koniec eksportuj plik ZIP za pomocą metody `SaveAs`.
```csharp
using IronZip;
using System.IO;
class Program
{
static void Main()
{
// Create a new ZIP file
using (var archive = new ZipArchive())
{
// Add a file to the archive
archive.AddArchiveEntry("example.txt", File.ReadAllBytes("path/to/example.txt"));
// Save the ZIP archive
archive.SaveAs("archive.zip");
}
}
}
```
### Rozpakowanie archiwum do folderu
Wydobądź zawartość z pliku ZIP za pomocą metody `ExtractArchiveToDirectory`. Określ ścieżkę docelowego pliku ZIP i katalog docelowy operacji wyodrębniania.
```csharp
using IronZip;
class Program
{
static void Main()
{
// path to the ZIP file and extraction directory
string zipPath = "archive.zip";
string extractPath = "extracted/";
// Extract all files in the ZIP archive to the specified directory
using (var archive = new ZipArchive(zipPath))
{
archive.ExtractArchiveToDirectory(extractPath);
}
}
}
```
### Dodaj pliki do istniejącego archiwum
Przekazanie ścieżki do pliku ZIP do konstruktora otworzy plik ZIP. Użyj tej samej metody `AddArchiveEntry`, aby dodać pliki do otwartego ZIP i wyeksportować go za pomocą metody `SaveAs`.
```csharp
using IronZip;
using System.IO;
class Program
{
static void Main()
{
// Open an existing ZIP file
using (var archive = new ZipArchive("archive.zip"))
{
// Add more files to the archive
archive.AddArchiveEntry("anotherfile.txt", File.ReadAllBytes("path/to/anotherfile.txt"));
// Save updates to the ZIP archive
archive.SaveAs("archive.zip");
}
}
}
```
## Licencjonowanie i wsparcie dostępne
**IronZIP** jest płatną biblioteką; jednakże, darmowe licencje próbne są również dostępne [tutaj](trial-license).
Aby uzyskać więcej informacji o Iron Software, odwiedź naszą stronę internetową: [https://ironsoftware.com/](https://ironsoftware.com/)
W przypadku dodatkowego wsparcia i zapytań, proszę [skontaktować się z naszym zespołem](#live-chat-support).
### Wsparcie od Iron Software
W przypadku ogólnego wsparcia i pytań technicznych, prosimy o kontakt mailowy na adres: [support@ironsoftware.com](mailto:support@ironsoftware.com)
IronZIP: Twoja uniwersalna biblioteka archiwów dla .NET
IronZIP jest biblioteką do kompresji i dekompresji archiwów opracowaną przez Iron Software. Oprócz powszechnie używanego formatu ZIP obsługuje również formaty TAR, GZIP i BZIP2.
Po zainstalowaniu możesz rozpocząć, dodając using IronZip; na początku kodu C#.
Stosowanie klucza licencyjnego
Następnie, zastosuj ważną licencję lub klucz próbny do IronZIP, przypisując klucz licencyjny do właściwości LicenseKey klasy License. Załącz następujący kod zaraz po instrukcji importu, przed użyciem jakichkolwiek metod IronZIP:
using IronZip;// Apply your license key hereIronZip.License.LicenseKey = "YOUR_LICENSE_KEY";
using IronZip;
// Apply your license key here
IronZip.License.LicenseKey = "YOUR_LICENSE_KEY";
ImportsIronZip' Apply your license key hereIronZip.License.LicenseKey = "YOUR_LICENSE_KEY"
Imports IronZip
' Apply your license key here
IronZip.License.LicenseKey = "YOUR_LICENSE_KEY"
Przykłady kodu
Przykład tworzenia archiwum
Utwórz plik ZIP za pomocą instrukcji using. W bloku using, użyj metody AddArchiveEntry, aby zaimportować pliki do pliku ZIP. Na koniec eksportuj plik ZIP za pomocą metody SaveAs.
using IronZip;using System.IO;class Program{ static voidMain() { // Create a new ZIP file using (var archive = new ZipArchive()) { // Add a file to the archive archive.AddArchiveEntry("example.txt", File.ReadAllBytes("path/to/example.txt")); // Save the ZIP archive archive.SaveAs("archive.zip"); } }}
using IronZip;
using System.IO;
class Program
{
static void Main()
{
// Create a new ZIP file
using (var archive = new ZipArchive())
{
// Add a file to the archive
archive.AddArchiveEntry("example.txt", File.ReadAllBytes("path/to/example.txt"));
// Save the ZIP archive
archive.SaveAs("archive.zip");
}
}
}
ImportsIronZipImportsSystem.IOFriend Class ProgramShared Sub Main() ' Create a new ZIP fileUsing archive = New ZipArchive() ' Add a file to the archive archive.AddArchiveEntry("example.txt", File.ReadAllBytes("path/to/example.txt")) ' Save the ZIP archive archive.SaveAs("archive.zip")EndUsing End SubEnd Class
Imports IronZip
Imports System.IO
Friend Class Program
Shared Sub Main()
' Create a new ZIP file
Using archive = New ZipArchive()
' Add a file to the archive
archive.AddArchiveEntry("example.txt", File.ReadAllBytes("path/to/example.txt"))
' Save the ZIP archive
archive.SaveAs("archive.zip")
End Using
End Sub
End Class
Rozpakowanie archiwum do folderu
Wydobądź zawartość z pliku ZIP za pomocą metody ExtractArchiveToDirectory. Określ ścieżkę docelowego pliku ZIP i katalog docelowy operacji wyodrębniania.
using IronZip;class Program{ static voidMain() { // path to the ZIP file and extraction directory string zipPath = "archive.zip"; string extractPath = "extracted/"; // Extract all files in the ZIP archive to the specified directory using (var archive = new ZipArchive(zipPath)) { archive.ExtractArchiveToDirectory(extractPath); } }}
using IronZip;
class Program
{
static void Main()
{
// path to the ZIP file and extraction directory
string zipPath = "archive.zip";
string extractPath = "extracted/";
// Extract all files in the ZIP archive to the specified directory
using (var archive = new ZipArchive(zipPath))
{
archive.ExtractArchiveToDirectory(extractPath);
}
}
}
ImportsIronZipFriend Class ProgramShared Sub Main() ' path to the ZIP file and extraction directory Dim zipPath AsString = "archive.zip" Dim extractPath AsString = "extracted/" ' Extract all files in the ZIP archive to the specified directoryUsing archive = New ZipArchive(zipPath) archive.ExtractArchiveToDirectory(extractPath)EndUsing End SubEnd Class
Imports IronZip
Friend Class Program
Shared Sub Main()
' path to the ZIP file and extraction directory
Dim zipPath As String = "archive.zip"
Dim extractPath As String = "extracted/"
' Extract all files in the ZIP archive to the specified directory
Using archive = New ZipArchive(zipPath)
archive.ExtractArchiveToDirectory(extractPath)
End Using
End Sub
End Class
Dodaj pliki do istniejącego archiwum
Przekazanie ścieżki do pliku ZIP do konstruktora otworzy plik ZIP. Użyj tej samej metody AddArchiveEntry, aby dodać pliki do otwartego ZIP i wyeksportować go za pomocą metody SaveAs.
using IronZip;using System.IO;class Program{ static voidMain() { // Open an existing ZIP file using (var archive = new ZipArchive("archive.zip")) { // Add more files to the archive archive.AddArchiveEntry("anotherfile.txt", File.ReadAllBytes("path/to/anotherfile.txt")); // Save updates to the ZIP archive archive.SaveAs("archive.zip"); } }}
using IronZip;
using System.IO;
class Program
{
static void Main()
{
// Open an existing ZIP file
using (var archive = new ZipArchive("archive.zip"))
{
// Add more files to the archive
archive.AddArchiveEntry("anotherfile.txt", File.ReadAllBytes("path/to/anotherfile.txt"));
// Save updates to the ZIP archive
archive.SaveAs("archive.zip");
}
}
}
ImportsIronZipImportsSystem.IOFriend Class ProgramShared Sub Main() ' Open an existing ZIP fileUsing archive = New ZipArchive("archive.zip") ' Add more files to the archive archive.AddArchiveEntry("anotherfile.txt", File.ReadAllBytes("path/to/anotherfile.txt")) ' Save updates to the ZIP archive archive.SaveAs("archive.zip")EndUsing End SubEnd Class
Imports IronZip
Imports System.IO
Friend Class Program
Shared Sub Main()
' Open an existing ZIP file
Using archive = New ZipArchive("archive.zip")
' Add more files to the archive
archive.AddArchiveEntry("anotherfile.txt", File.ReadAllBytes("path/to/anotherfile.txt"))
' Save updates to the ZIP archive
archive.SaveAs("archive.zip")
End Using
End Sub
End Class
Licencjonowanie i wsparcie dostępne
IronZIP jest płatną biblioteką; jednakże, darmowe licencje próbne są również dostępne tutaj.
Curtis Chau posiada tytuł licencjata z informatyki (Uniwersytet Carleton) i specjalizuje się w front-endowym rozwoju, z ekspertką w Node.js, TypeScript, JavaScript i React. Pasjonuje się tworzeniem intuicyjnych i estetycznie przyjemnych interfejsów użytkownika, Curtis cieszy się pracą z nowoczesnymi frameworkami i tworzeniem dobrze zorganizowanych, atrakcyjnych wizualnie podręczników.