# Primeiros passos com o IronZIP
## IronZIP: Sua biblioteca de arquivos completa para .NET
**IronZIP** é uma biblioteca de compressão e descompressão de arquivos desenvolvida pela Iron Software. Além do formato ZIP, amplamente utilizado, ele também é compatível com TAR, GZIP e BZIP2.
### Biblioteca de Compressão e Descompressão de Arquivos para C#
1. [Baixe a biblioteca C# para compressão e descompressão de arquivos.](https://www.nuget.org/packages/IronZip/)
2. Suporta os formatos ZIP, TAR, GZIP e BZIP2.
3. Personalize os níveis de compressão de 0 a 9.
4. Extrair conteúdo de arquivos compactados
5. Anexe arquivos a arquivos ZIP existentes e gere novos arquivos ZIP.
### Compatibilidade
**O IronZIP** possui compatibilidade multiplataforma com:
#### Suporte à versão .NET :
- **C#** , **VB .NET** , **F#**
- **.NET 7, 6** , 5 e Core 3.1+
- .NET Standard (2.0+)
- .NET Framework (4.6.2 ou superior)
#### Suporte a sistemas operacionais e ambientes:
- **Windows** (10+, Servidor 2016+)
- **Linux** (Ubuntu, Debian, CentOS, etc.)
- **macOS** (10+)
- **iOS** (12+)
- **Android** API 21+ (v5 "Lollipop")
- **Docker** (Windows, Linux, Azure)
- **Azure** (VPS, WebApp, Função)
- **AWS** (EC2, Lambda)
#### Suporte a tipos de projeto .NET :
- **Web** (Blazor e WebForms)
- **Dispositivos móveis** (Xamarin e MAUI)
- **Desktop** (WPF e MAUI)
- **Console** (Aplicativo e Biblioteca)
## Instalação
### Biblioteca IronZIP
Para instalar o pacote IronZIP , utilize o seguinte comando no seu terminal ou console do gerenciador de pacotes:
```shell
:ProductInstall
```
Alternativamente, faça o download diretamente do [site oficial do IronZIP no NuGet](https://www.nuget.org/packages/IronZip) .
Uma vez instalado, você pode começar adicionando `using IronZip;` ao topo do seu código C#.
## Aplicando a chave de licença
Em seguida, aplique uma licença válida ou chave de avaliação ao IronZIP atribuindo a chave de licença à propriedade LicenseKey da classe License. Inclua o seguinte código logo após a declaração de importação, antes de usar qualquer método do IronZIP :
```csharp
using IronZip;
// Apply your license key here
IronZip.License.LicenseKey = "YOUR_LICENSE_KEY";
```
## Exemplos de código
### Criar um exemplo de arquivo
Crie um arquivo ZIP usando a instrução `using`. Dentro do bloco using, use o método `AddArchiveEntry` para importar arquivos no arquivo ZIP. Finalmente, exporte o arquivo ZIP com o método `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");
}
}
}
```
### Descompactar um arquivo para uma pasta
Extraia o conteúdo do arquivo ZIP usando o método `ExtractArchiveToDirectory`. Especifique o caminho do arquivo ZIP de destino e o diretório de extração.
```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);
}
}
}
```
### Adicionar arquivos a um arquivo existente
Passar o caminho do arquivo ZIP para o construtor abrirá o arquivo ZIP. Utilize o mesmo método `AddArchiveEntry` para adicionar arquivos ao ZIP aberto e exportá-lo com o método `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");
}
}
}
```
## Licenciamento e suporte disponíveis
**IronZIP** é uma biblioteca paga; no entanto, licenças de avaliação gratuitas também estão disponíveis [aqui](trial-license).
Para obter mais informações sobre a Iron Software, visite nosso site:[https://ironsoftware.com/](https://ironsoftware.com/)
Para obter mais suporte e esclarecer dúvidas, [entre em contato com nossa equipe](#live-chat-support) .
### Suporte da Iron Software
Para suporte geral e dúvidas técnicas, envie um e-mail para:[support@ironsoftware.com](mailto:support@ironsoftware.com)
IronZIP: Sua biblioteca de arquivos completa para .NET
IronZIP é uma biblioteca de compressão e descompressão de arquivos desenvolvida pela Iron Software. Além do formato ZIP, amplamente utilizado, ele também é compatível com TAR, GZIP e BZIP2.
Biblioteca de Compressão e Descompressão de Arquivos para C#
Uma vez instalado, você pode começar adicionando using IronZip; ao topo do seu código C#.
Aplicando a chave de licença
Em seguida, aplique uma licença válida ou chave de avaliação ao IronZIP atribuindo a chave de licença à propriedade LicenseKey da classe License. Inclua o seguinte código logo após a declaração de importação, antes de usar qualquer método do 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"
Exemplos de código
Criar um exemplo de arquivo
Crie um arquivo ZIP usando a instrução using. Dentro do bloco using, use o método AddArchiveEntry para importar arquivos no arquivo ZIP. Finalmente, exporte o arquivo ZIP com o método 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
Descompactar um arquivo para uma pasta
Extraia o conteúdo do arquivo ZIP usando o método ExtractArchiveToDirectory. Especifique o caminho do arquivo ZIP de destino e o diretório de extração.
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
Adicionar arquivos a um arquivo existente
Passar o caminho do arquivo ZIP para o construtor abrirá o arquivo ZIP. Utilize o mesmo método AddArchiveEntry para adicionar arquivos ao ZIP aberto e exportá-lo com o método 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
Licenciamento e suporte disponíveis
IronZIP é uma biblioteca paga; no entanto, licenças de avaliação gratuitas também estão disponíveis aqui.
Curtis Chau é bacharel em Ciência da Computação (Universidade Carleton) e se especializa em desenvolvimento front-end, com experiência em Node.js, TypeScript, JavaScript e React. Apaixonado por criar interfaces de usuário intuitivas e esteticamente agradáveis, Curtis gosta de trabalhar com frameworks modernos e criar manuais bem estruturados e visualmente atraentes.