C1.Xaml.Zip アセンブリ > C1.C1Zip 名前空間 : C1ZipFile クラス |
C1Zip ファイルオブジェクトをディスク内の zip ファイルに関連付けるには、Open(string) メソッドまたは Create(string) メソッドを使用します。次に、zip ファイル内の個々のエントリを追加、削除、取得、または調査するには、Entries プロパティを使用します。
C1ZipFile は、標準の zip ファイルでのみ使用できます。このコンポーネントは、gzip、zip2、tar、rar などの他の似た形式をサポートしません。
標準の zip ファイルは、各エントリのサイズに制限を課します。これを使用して、4ギガバイト(uint.MaxValue)を超えるファイルを圧縮することはできません。
// zip ファイルと圧縮するファイルのパスを取得します string path = Application.ExecutablePath; int pos = path.IndexOf(@"\bin"); path = path.Substring(0, pos + 1); // zip ファイルを作成します C1ZipFile zip = new C1ZipFile(); zip.Create(path + "source.zip"); // cs 拡張子を持つすべてのファイルを zip ファイルに追加します foreach (string fileName in Directory.GetFiles(path, "*.cs")) zip.Entries.Add(fileName); // 結果を表示します foreach (C1ZipEntry ze in zip.Entries) { Console.WriteLine("{0} {1:#,##0} {2:#,##0}", ze.FileName, ze.SizeUncompressed, ze.SizeCompressed); }
System.Object
C1.C1Zip.C1ZipFile
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2