/// <summary> /// 批量解压事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnBatchUnZipFlo_Click(object sender, EventArgs e) { string msg = ""; string path2 = "D:\\Debug2\\"; string path3 = "D:\\Debug3\\"; //获取指定目录下所有文件和子文件名称(所有待解压的压缩文件) string[] files = Directory.GetFileSystemEntries(path2); UnZipFloClass uzc = new UnZipFloClass(); //遍历所有压缩文件路径 foreach (string file in files) { //获取压缩包名称(包括后缀名) var filename = file.Substring(file.LastIndexOf("\\") + 1); //得到压缩包名称(没有后缀) filename = filename.Substring(0, filename.LastIndexOf(".")); //判断解压的路径是否存在 if (!Directory.Exists(path3 + filename)) { //没有,则创建这个路径 Directory.CreateDirectory(path3 + filename); } //调用解压方法(参数1:待解压的压缩文件路径(带后缀名),参数2:解压后存放的文件路径,参数3:返工是否解压成功) uzc.unZipFile(file, path3 + filename, ref msg); } MessageBox.Show("批量解压成功"); }
static void Main2(string[] args) { if (args.Length > 0) { Console.WriteLine("执行:" + args[0]); if (args[0] == "-e") { string[] FileProperties = new string[2]; FileProperties[0] = "D:\\123\\unzipped\\"; //待压缩文件目录 FileProperties[1] = "D:\\123\\zip\\a.zip"; //压缩后的目标文件 ZipFloClass Zc = new ZipFloClass(); Zc.ZipFile(FileProperties[0], FileProperties[1]); } else if (args[0] == "-d") { string[] FileProperties = new string[2]; FileProperties[0] = "D:\\123\\zip\\a.zip"; //待解压的文件 FileProperties[1] = "D:\\123\\unzipped2\\"; //解压后放置的目标目录 UnZipFloClass UnZc = new UnZipFloClass(); UnZc.unZipFile(FileProperties[0], FileProperties[1]); } } else { Console.WriteLine("无效的命令行:" + args[0]); } }
/// <summary> /// 解压事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUnZipFlo_Click(object sender, EventArgs e) { string[] strs = new string[2]; string msg = ""; //待解压的文件 strs[0] = "D:\\Debug2\\FrpTest.zip"; //解压后放置的目标文件 strs[1] = "D:\\Debug3"; UnZipFloClass uzc = new UnZipFloClass(); uzc.unZipFile(strs[0], strs[1], ref msg); MessageBox.Show("信息:" + msg); }