private static void CreatHotterZip(int preVersionNum) { if (preVersionNum == CurVersionNum || preVersionNum < int.Parse(TheVersionNum[2])) { return; } Debug.Log("Update Version From :" + preVersionNum + " to " + CurVersionNum); Dictionary <string, List <string> > preVersionMd5 = ABHelper.ReadVersionFile(PlatformABExportPath + "/" + preVersionNum.ToString() + "/" + ABHelper.VersionFileName); // 需要更新的文件 Dictionary <string, string> updateFiles = new Dictionary <string, string>(); foreach (KeyValuePair <string, List <string> > pair in CurVersionList) { string path = pair.Key; string md5 = pair.Value[0]; string verId = pair.Value[1]; string name = pair.Value[3]; List <string> oldMd5Info = null; if (preVersionMd5.TryGetValue(path, out oldMd5Info)) { if (oldMd5Info[0] != md5 || oldMd5Info[1] != verId) { updateFiles.Add(name, verId); } } else { updateFiles.Add(name, verId); } } // version添加进来 if (File.Exists(CurVersionABExportPath + ABHelper.VersionFileName) && !updateFiles.ContainsKey(ABHelper.VersionFileName)) { updateFiles.Add(ABHelper.VersionFileName, CurVersionNum.ToString()); } // 生成更新文件夹 string zipFolder = ABExportHotterZipPath + preVersionNum + "-" + CurVersionNum; if (Directory.Exists(zipFolder)) { Directory.Delete(zipFolder, true); } Directory.CreateDirectory(zipFolder); // 复制到更新文件夹下 foreach (var fileInfo in updateFiles) { string sourceFile = PlatformABExportPath + "/" + fileInfo.Value + "/" + fileInfo.Key; string copyFile = zipFolder + "/" + fileInfo.Value + "/" + fileInfo.Key; if (File.Exists(copyFile)) { File.Delete(copyFile); } string copyPath = Path.GetDirectoryName(copyFile); if (!Directory.Exists(copyPath)) { Directory.CreateDirectory(copyPath); } // 资源拷贝 File.Copy(sourceFile, copyFile, true); } // 压缩 string zipFullName = zipFolder + ".zip"; zipFolder = zipFolder.Replace("\\", "/"); DirectoryInfo sourzeZipFolder = new DirectoryInfo(zipFolder); FastZipEvents zipEvents = new FastZipEvents(); zipEvents.DirectoryFailure = DirectoryFailureHandler; zipEvents.FileFailure = FileFailureHandler; zipEvents.Progress = ProgressHandler; // 压缩前的文件大小 filePreSize = 0; fileZipSize = 0; foreach (var path in ABHelper.GetAllFilesPathInDir(sourzeZipFolder.FullName)) { FileInfo fileInfo = new FileInfo(path); filePreSize += fileInfo.Length; } // 进行压缩 ZipSuccess = true; ABHelper.ZipFile(zipFullName, sourzeZipFolder.FullName, zipEvents); while (!ZipSuccess) { ZipSuccess = true; ABHelper.ZipFile(zipFullName, sourzeZipFolder.FullName, zipEvents); } EditorUtility.ClearProgressBar(); // 压缩后的文件大小 // 1-2.ini FileInfo zipfile = new FileInfo(zipFullName); ABHelper.WriteFile(zipFolder + ".ini", ("zipsize:" + zipfile.Length + ":" + filePreSize)); }