VS2010 C# 壓縮單一檔案(使用.NET 4 內建元件)
VS2010 C# 壓縮單一檔案(使用.NET 4 內建元件)
資料來源: https://msdn.microsoft.com/zh-tw/library/ms404280(v=vs.100).aspx
using System; using System.Collections.Generic; using System.Linq; using System.Text; //https://msdn.microsoft.com/zh-tw/library/ms404280(v=vs.100).aspx using System.IO; using System.IO.Compression; namespace Console_CS_zip { class Program { public { // Get using { // // if & != FileAttributes.Hidden { // using { using (GZipStream Compress = new GZipStream(outFile, { // Copy the source file into // the compression stream. fi.Name, } } } } } static { Console.Write(“Press any key to continue . . . “); Console.ReadKey(true); } static { // Path string DirectoryInfo di = new DirectoryInfo(dirpath); // foreach { Compress(fi); } Pause(); /* // Decompress all *.gz foreach (FileInfo fi { Decompress(fi); } */ } } } |