在程序里面(服务器端)调用Winrar压缩文件的方法。(1) 1case("zip"): // 压缩 2 string[] zip_tmp = this.name1.Value.Split(new char[]{'*'}); 3 string zip_tmp1= zip_tmp[zip_tmp.Length-1]; 4 if(this.CheckName(zip_tmp1)) //检测文件命名的合法性 5 { 6 string zip_tmp2=zip_tmp1.Replace(".zip",""); 7 8 //移除“.zip”后缀,并防止名称重复 910 this.NameExisted(1,ServerDir+@"personal\"+zip_tmp2+".zip",out zip_tmp2);11 StreamWriter zip_sr =File.CreateText(ServerDir+"list.dat");12 zip_sr.Write("");13 zip_sr.Close();14 for(int m =0;m<zip_tmp.Length-1;m++)15 {16 //以系统默认的 ANSI 编码创建压缩文件列表1718 StreamWriter zip_sw2 =new StreamWriter(ServerDir+"list.dat",true,System.Text.Encoding.Default); 19 zip_sw2.WriteLine(ServerDir+zip_tmp[m]);20 zip_sw2.Close();21 }22 System.DiagnostiCS.Process Process1=new System.Diagnostics.Process();23 Process1.StartInfo.FileName=ServerDir+"WinRAR.exe";24 Process1.StartInfo.Arguments=" a -ep1 -inul -y "+zip_tmp2+@" @"+ServerDir+"list.dat";