Calling C # 's own API for compression
Zip
Destfullpath = destfullpath + "\" + _myconfig.zipfilename;
if (file.exists (Destfullpath))
file.delete (destfullpath);
Zipfile.createfromdirectory (_myconfig.tempfilefolder, Destfullpath);
Call WinRAR for compression
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks; Namespace Testzipexe {class Program {static void Main (string[] args) {string Exepat
h = "C:\\Program Files (x86) \\WinRAR\\winrar.exe";
* * A To add a document, must have, otherwise will not output compressed files. *-K Lock Compressed files *-R including subdirectories *-M1 use the fastest way (low compression) *-EP1 exclude the base folder, or the compressed package will contain the folder to be compressed
Full path *-o+ Overwrite existing file *-afzip specify compressed format as Zip * destination file (full path) * source folder * */String parameters = String.Format ("A-k-m1-ep1-afzip-r-o+ d:\\workspace\\cat8637_brand_2 0150211\\trunk\\cat8637_brand\\dest\\brand.zip d:\\workspace\\cat8637_brand_20150211\\trunk\\cat8637_brand\\
Temp\\brand ");
EXEC (exepath, parameters);
Console.WriteLine ("End"); static public void exec (string exepath, string parameters) {System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStar
Tinfo (); Psi.
Redirectstandardoutput = true; Psi.
Redirectstandarderror = true; Psi.
WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; Psi.
UseShellExecute = false; Psi.
FileName = ExePath; Psi.
Arguments = parameters;
System.Diagnostics.Process Process = System.Diagnostics.Process.Start (PSI); System.IO.StreamReader Outputstreamreader = process.
StandardOutput; System.IO.StreamReader Errstreamreader = process.
StandardError;
int i = 0; do {process.
WaitForExit (2000);
i++; while (process.
HasExited = = False && i < 15); if (process.
hasexited)//{//String output = Outputstreamreader.readtoend (); String ERror = Errstreamreader.readtoend ();
MessageBox.Show (output);
MessageBox.Show (Error);
//}
}
}
}