static void Main(string[] args) { Console.WriteLine("是否压缩当前目录的所有文件夹,y:是 n:否"); string s = Console.ReadLine(); if (s == "y") { string basepath = AppDomain.CurrentDomain.BaseDirectory; DirectoryInfo basedirinfo = new DirectoryInfo(basepath); foreach (DirectoryInfo dir in basedirinfo.GetDirectories()) { FastZipHelper.compress(dir.FullName, dir.FullName + ".zip"); Console.WriteLine("正在压缩" + dir.FullName + "..."); } Console.WriteLine("压缩完成"); Console.ReadLine(); } }
private void btnzip_Click(object sender, EventArgs e) { List <string> paths = getexceptDir(); string srcfile = prjpath + "_src"; if (File.Exists(srcfile + ".zip")) { File.Delete(srcfile + ".zip"); } Directory.CreateDirectory(srcfile); CommonHelper.CopyFolder(prjpath, srcfile, paths); FastZipHelper.compress(srcfile, srcfile + ".zip"); Directory.Delete(srcfile, true); srcfile_zip = srcfile + ".zip"; isOk = true; this.Close(); }
//插件打包上传 private void btnpackup_Click(object sender, EventArgs e) { try { if (File.Exists(prjpath + ".zip")) { File.Delete(prjpath + ".zip"); } string temp = prjpath + "_temp"; Directory.CreateDirectory(temp); foreach (issueClass ic in plugin.issue) { if (ic.type == "dir") { if (ic.source != "") { CommonHelper.CopyFolder(prjpath + "\\" + ic.source, temp + "\\" + ic.path); } else { if (Directory.Exists(prjpath + "\\" + ic.path)) { CommonHelper.CopyFolder(prjpath + "\\" + ic.path, temp + "\\" + ic.path); } else { Directory.CreateDirectory(temp + "\\" + ic.path); } } } else if (ic.type == "file") { if (ic.source != "") { new FileInfo(prjpath + "\\" + ic.source).CopyTo(temp + "\\" + ic.path, true); } else { new FileInfo(prjpath + "\\" + ic.path).CopyTo(temp + "\\" + ic.path, true); } } } FastZipHelper.compress(temp, prjpath + ".zip"); Directory.Delete(temp, true); //txtdownloadpath.Text = prjpath + ".zip"; txtpluginsize.Text = CommonHelper.GetFileCountSize(prjpath + ".zip"); frmprogress progress = new frmprogress(); string url = CommonHelper.plugin_serverurl + "/Controller.aspx?controller=efwplus_website@PluginController&method=uploadfile"; //上传 UpDownLoadFileHelper updown = new UpDownLoadFileHelper(); updown.Cdelegate = new UpDownLoadFileHelper.controldelegate(progress.refreshControl); updown.UpDown = UpDownLoadFileHelper.updown.; updown.Completed = delegate() { txtdownloadpath.Text = "/ModulePlugin/efwplus_website/pluginpackage/" + prjname + ".zip"; //System.Threading.Thread.Sleep(2000); progress.Close(); }; updown.Cancelled = delegate() { progress.Close(); }; updown.Start(url, prjpath + ".zip"); progress.ShowDialog(); } catch (Exception err) { MessageBoxEx.Show("上传插件包失败!\n" + err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }