透かしなしで本番環境でテストしてください。
必要な場所で動作します。
30日間、完全に機能する製品をご利用いただけます。
数分で稼働させることができます。
製品トライアル期間中にサポートエンジニアリングチームへの完全アクセス
ファイルエントリの圧縮およびアーカイブユーティリティの分野では、7-Zipが多用途でオープンソースのソリューションとして際立っています。 高い圧縮率とさまざまなアーカイブ形式のサポートで知られるSevenZipは、効率的なファイル管理を求めるユーザーにとって人気の選択肢となっています。 この記事では、7-Zipとは何か、その仕組み、主な機能、ユニークな7z形式、圧縮率、および7zアーカイブの作成に役立つC#用の.NET SDKについて探ります。 さらに、.NETエコシステムの代替ソリューションとしてIronZIPを導入します。
SevenZipまたは7-Zipは、ファイルを圧縮および解凍するためにユーザーが使用できる、無料かつオープンソースのファイルアーカイバユーティリティです。 イゴール・パヴロフによって開発された7-Zipは、幅広い圧縮形式をサポートしており、データの管理と整理に多用途に使用できるツールです。
7-Zipは、ファイルやフォルダーのサイズを削減するために、先進的な圧縮アルゴリズムを利用しています。 それはネイティブの7zフォーマットにLZMA(Lempel-Ziv-Markov chain-Algorithm)圧縮アルゴリズムを採用しており、その結果として優れた圧縮率を提供します。 そのユーティリティは、ZIP、TAR、およびGZIPなどの一般的な形式もサポートしています。
7z形式は7-Zipがアーカイブに使用する専用形式です。 それは、優れた圧縮比で知られるLZMA圧縮アルゴリズムを採用しています。 7z形式は、連結圧縮、ファイル分割、自己解凍アーカイブなどの機能をサポートしています。
7-Zipは、特にLZMAアルゴリズムを使用した7z形式での優れた圧縮率で有名です。 この効率により、圧縮ファイルの完全性を損なうことなく、アーカイブサイズを小さくすることができます。 7-Zipで作成されたファイルは、通常のZIP形式よりも30〜70%圧縮されます。
C#で開発を行っている開発者向けに、7-Zipはカスタムアプリケーションに7-Zip機能をシームレスに統合することを可能にする.NET SDKを提供しています。 このSDKは、開発者が圧縮および解凍操作をプログラムにより実行できるようにし、C#プロジェクト内でアーカイブされたファイルを柔軟に管理することができます。
C#アプリケーションで7-Zipを使用したい場合、7-Zip SDKを利用するか、C#コード内でコマンドライン実行可能ファイルを利用することができます。 以下は、両方のアプローチの簡単な概要です。
7-Zip SDKには7z.dllライブラリが含まれており、これをC#プロジェクトで使用することができます。 このアプローチにより、プログラム上で圧縮および解凍操作を実行することができます。
以下は7-Zip SDKを使用したソースコードの例です:
using SevenZip;
class Program
{
static void Main()
{
// Specify the path to the 7z.dll library
SevenZipBase.SetLibraryPath("path_to_7z.dll");
// Create a SevenZipExtractor or SevenZipCompressor instance
// Perform compression or decompression operations as needed
// Example: Extract files from an archive
using (var extractor = new SevenZipExtractor("archive.7z"))
{
extractor.ExtractArchive("output_directory");
}
// Example: Compress files into an archive
using (var compressor = new SevenZipCompressor())
{
// Add File entry in archive
compressor.CompressFiles("archive.7z", "file1.txt", "file2.txt");
}
}
}
using SevenZip;
class Program
{
static void Main()
{
// Specify the path to the 7z.dll library
SevenZipBase.SetLibraryPath("path_to_7z.dll");
// Create a SevenZipExtractor or SevenZipCompressor instance
// Perform compression or decompression operations as needed
// Example: Extract files from an archive
using (var extractor = new SevenZipExtractor("archive.7z"))
{
extractor.ExtractArchive("output_directory");
}
// Example: Compress files into an archive
using (var compressor = new SevenZipCompressor())
{
// Add File entry in archive
compressor.CompressFiles("archive.7z", "file1.txt", "file2.txt");
}
}
}
Imports SevenZip
Friend Class Program
Shared Sub Main()
' Specify the path to the 7z.dll library
SevenZipBase.SetLibraryPath("path_to_7z.dll")
' Create a SevenZipExtractor or SevenZipCompressor instance
' Perform compression or decompression operations as needed
' Example: Extract files from an archive
Using extractor = New SevenZipExtractor("archive.7z")
extractor.ExtractArchive("output_directory")
End Using
' Example: Compress files into an archive
Using compressor = New SevenZipCompressor()
' Add File entry in archive
compressor.CompressFiles("archive.7z", "file1.txt", "file2.txt")
End Using
End Sub
End Class
「path_to_7z.dll」を7z.dllライブラリの実際のパスに置き換えてください。 7z.dllファイルは7-Zipのインストールディレクトリにあります。
別の方法として、System.Diagnostics.Process
クラスを介して呼び出すことにより、C#ソースコード内で7-Zipコマンドライン実行可能ファイル(7z.exe)を使用できます。
using System.Diagnostics;
class Program
{
static void Main()
{
// Example: Extract files from an archive using the command-line executable
string archivePath = "archive.7z";
string outputPath = "output_directory";
ProcessStartInfo processStartInfo = new ProcessStartInfo
{
FileName = "7z.exe",
Arguments = $"x \"{archivePath}\" -o\"{outputPath}\"",
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
};
using (Process process = new Process { StartInfo = processStartInfo })
{
process.Start();
process.WaitForExit();
}
}
}
using System.Diagnostics;
class Program
{
static void Main()
{
// Example: Extract files from an archive using the command-line executable
string archivePath = "archive.7z";
string outputPath = "output_directory";
ProcessStartInfo processStartInfo = new ProcessStartInfo
{
FileName = "7z.exe",
Arguments = $"x \"{archivePath}\" -o\"{outputPath}\"",
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
};
using (Process process = new Process { StartInfo = processStartInfo })
{
process.Start();
process.WaitForExit();
}
}
}
Imports System.Diagnostics
Friend Class Program
Shared Sub Main()
' Example: Extract files from an archive using the command-line executable
Dim archivePath As String = "archive.7z"
Dim outputPath As String = "output_directory"
Dim processStartInfo As New ProcessStartInfo With {
.FileName = "7z.exe",
.Arguments = $"x ""{archivePath}"" -o""{outputPath}""",
.RedirectStandardOutput = True,
.UseShellExecute = False,
.CreateNoWindow = True
}
Using process As New Process With {.StartInfo = processStartInfo}
process.Start()
process.WaitForExit()
End Using
End Sub
End Class
"7z.exe" がシステムの PATH に含まれていることを確認するか、FileName
プロパティで実行可能ファイルのフルパスを指定してください。
7-Zipは堅牢なソリューションですが、.NETエコシステム内で代替案を検討する開発者にとって、IronZIPは魅力的な選択肢となり得ます。IronZIPは.NET圧縮ライブラリであり、7-Zipに似た機能を提供し、開発者に対してC#アプリケーション内でアーカイブを圧縮、解凍、操作するためのツールを提供します。
IronZIPは、.NETアプリケーションでZIPファイルを扱うことを簡素化する強力なC# ZIPアーカイブライブラリです。 使いやすいAPIにより、開発者はIronZIPを使用してZIPアーカイブの作成、読み取り、抽出を効率的に行えます。 こちらは、IronZIPを使用してZIPアーカイブを作成する簡単なコードスニペットです:
using IronZip;
class Program
{
static void Main()
{
// Specify the path for the new ZIP archive
string zipFilePath = "output.zip";
// Create an empty ZIP archive
using (var archive = new IronArchive(zipFilePath))
{
// Add files to the ZIP
archive.AddArchiveEntry("./assets/file1.txt");
archive.AddArchiveEntry("./assets/file2.jpg");
archive.AddArchiveEntry("./assets/file3.pdf");
}
Console.WriteLine("ZIP archive created successfully!");
}
}
using IronZip;
class Program
{
static void Main()
{
// Specify the path for the new ZIP archive
string zipFilePath = "output.zip";
// Create an empty ZIP archive
using (var archive = new IronArchive(zipFilePath))
{
// Add files to the ZIP
archive.AddArchiveEntry("./assets/file1.txt");
archive.AddArchiveEntry("./assets/file2.jpg");
archive.AddArchiveEntry("./assets/file3.pdf");
}
Console.WriteLine("ZIP archive created successfully!");
}
}
Imports IronZip
Friend Class Program
Shared Sub Main()
' Specify the path for the new ZIP archive
Dim zipFilePath As String = "output.zip"
' Create an empty ZIP archive
Using archive = New IronArchive(zipFilePath)
' Add files to the ZIP
archive.AddArchiveEntry("./assets/file1.txt")
archive.AddArchiveEntry("./assets/file2.jpg")
archive.AddArchiveEntry("./assets/file3.pdf")
End Using
Console.WriteLine("ZIP archive created successfully!")
End Sub
End Class
IronZIPおよびその機能やコード例の詳細については、IronZIPドキュメントページをご覧ください。
7-Zipは、ファイル圧縮の世界で依然として支配的な存在であり、ユーザーにオープンソースで豊富な機能を持つ解決策と、卓越した圧縮率を提供しています。 その多様なアーカイブ形式のサポートと強力な暗号化機能により、カジュアルなユーザーと開発者の両方にとって多用途の選択となります。.NET SDKは、C#開発者向けにその実用性をさらに拡張し、カスタムアプリケーションへのシームレスな統合を促進します。 .NET環境で別の選択肢を探している方には、IronZIPが注目に値する候補となります。これはC#開発者の特定のニーズに合わせた同様の機能を提供します。
IronZIPはIronZIPの無料試用版を提供しています。 IronZIPダウンロードページからIronZIP .NET CoreおよびFrameworkライブラリをダウンロードして試してください。