|
この記事は機械翻訳されたものです。 記事の文章にポインターを重ねると、原文のテキストが表示されます。 詳細情報
|
訳文
原文
|
GZipStream クラス
名前空間: System.IO.Compression
アセンブリ: System (System.dll 内)
GZipStream 型で公開されるメンバーは以下のとおりです。
| 名前 | 説明 | |
|---|---|---|
![]() ![]() | GZipStream(Stream, CompressionLevel) | |
![]() ![]() ![]() ![]() | GZipStream(Stream, CompressionMode) | |
![]() ![]() | GZipStream(Stream, CompressionLevel, Boolean) | |
![]() ![]() ![]() ![]() | GZipStream(Stream, CompressionMode, Boolean) |
| 名前 | 説明 | |
|---|---|---|
![]() ![]() ![]() ![]() | BaseStream | |
![]() ![]() ![]() ![]() | CanRead | |
![]() ![]() ![]() ![]() | CanSeek | |
![]() ![]() ![]() ![]() | CanTimeout | |
![]() ![]() ![]() ![]() | CanWrite | |
![]() ![]() ![]() ![]() | Length | |
![]() ![]() ![]() ![]() | Position | |
![]() ![]() ![]() ![]() | ReadTimeout | |
![]() ![]() ![]() ![]() | WriteTimeout |
| 名前 | 説明 | |
|---|---|---|
![]() ![]() ![]() | BeginRead | |
![]() ![]() ![]() | BeginWrite | |
![]() ![]() | Close | |
![]() ![]() ![]() | CopyTo(Stream) | |
![]() ![]() ![]() | CopyTo(Stream, Int32) | |
![]() ![]() | CopyToAsync(Stream) | |
![]() ![]() | CopyToAsync(Stream, Int32) | |
![]() ![]() | CopyToAsync(Stream, Int32, CancellationToken) | |
![]() | CreateObjRef | |
![]() ![]() | CreateWaitHandle | 互換性のために残されています。 |
![]() ![]() ![]() ![]() | Dispose() | |
![]() ![]() ![]() ![]() | Dispose(Boolean) | |
![]() ![]() ![]() | EndRead | |
![]() ![]() ![]() | EndWrite | |
![]() ![]() ![]() ![]() | Equals(Object) | |
![]() ![]() ![]() ![]() | Finalize | |
![]() ![]() ![]() ![]() | Flush | |
![]() ![]() | FlushAsync() | |
![]() ![]() | FlushAsync(CancellationToken) | |
![]() ![]() ![]() ![]() | GetHashCode | |
![]() | GetLifetimeService | |
![]() ![]() ![]() ![]() | GetType | |
![]() | InitializeLifetimeService | |
![]() ![]() ![]() ![]() | MemberwiseClone() | |
![]() | MemberwiseClone(Boolean) | |
![]() | ObjectInvariant | インフラストラクチャ。 互換性のために残されています。 |
![]() ![]() ![]() ![]() | Read | |
![]() ![]() | ReadAsync(Byte[], Int32, Int32) | |
![]() ![]() | ReadAsync(Byte[], Int32, Int32, CancellationToken) | |
![]() ![]() ![]() ![]() | ReadByte | |
![]() ![]() ![]() ![]() | Seek | |
![]() ![]() ![]() ![]() | SetLength | |
![]() ![]() ![]() ![]() | ToString | |
![]() ![]() ![]() ![]() | Write | |
![]() ![]() | WriteAsync(Byte[], Int32, Int32) | |
![]() ![]() | WriteAsync(Byte[], Int32, Int32, CancellationToken) | |
![]() ![]() ![]() ![]() | WriteByte |
| 名前 | 説明 | |
|---|---|---|
![]() ![]() | AsInputStream | |
![]() ![]() | AsOutputStream |
using System; using System.IO; using System.IO.Compression; namespace zip { public class Program { public static void Main() { string directoryPath = @"c:\users\public\reports"; DirectoryInfo directorySelected = new DirectoryInfo(directoryPath); foreach (FileInfo fileToCompress in directorySelected.GetFiles()) { Compress(fileToCompress); } foreach (FileInfo fileToDecompress in directorySelected.GetFiles("*.gz")) { Decompress(fileToDecompress); } } public static void Compress(FileInfo fileToCompress) { using (FileStream originalFileStream = fileToCompress.OpenRead()) { if ((File.GetAttributes(fileToCompress.FullName) & FileAttributes.Hidden) != FileAttributes.Hidden & fileToCompress.Extension != ".gz") { using (FileStream compressedFileStream = File.Create(fileToCompress.FullName + ".gz")) { using (GZipStream compressionStream = new GZipStream(compressedFileStream, CompressionMode.Compress)) { originalFileStream.CopyTo(compressionStream); Console.WriteLine("Compressed {0} from {1} to {2} bytes.", fileToCompress.Name, fileToCompress.Length.ToString(), compressedFileStream.Length.ToString()); } } } } } public static void Decompress(FileInfo fileToDecompress) { using (FileStream originalFileStream = fileToDecompress.OpenRead()) { string currentFileName = fileToDecompress.FullName; string newFileName = currentFileName.Remove(currentFileName.Length - fileToDecompress.Extension.Length); using (FileStream decompressedFileStream = File.Create(newFileName)) { using (GZipStream decompressionStream = new GZipStream(originalFileStream, CompressionMode.Decompress)) { decompressionStream.CopyTo(decompressedFileStream); Console.WriteLine("Decompressed: {0}", fileToDecompress.Name); } } } } } }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (サーバー コア ロールはサポート対象外), Windows Server 2008 R2 (SP1 以降でサーバー コア ロールをサポート。Itanium はサポート対象外)
.NET Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。


