string _appPath = new DirectoryInfo(Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName).Parent.FullName; if (!_appPath.EndsWith(@"\")) { _appPath += @"\"; } string s7z = _appPath + "7z.exe"; if (File.Exists(s7z)) { System.Diagnostics.Process pNew = new System.Diagnostics.Process(); pNew.StartInfo.FileName = s7z; pNew.StartInfo.Arguments = string.Format(" a -tzip {0} {1}", zipFileFullName, backupFileFullName); pNew.Start(); //一定要等待完成后,才能删除。 pNew.WaitForExit(); //压完后删除原有的 File.Delete(backupFileFullName); } else { sMsg = "找不到7z.exe。"; return false; }
--