private bool VerificationFile(UpdateFileInfo updateFileInfo, string filePath) { // return true; var length = 0; using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.ReadWrite)) { length = (int)fileStream.Length; if (length != updateFileInfo.ZipLength) { FileUtility.DeleteFile(filePath); return(false); } if (updateFileCache == null || updateFileCache.Length < length) { updateFileCache = new byte[(length / OneMegaBytes + 1) * OneMegaBytes]; } int offset = 0; int count = length; while (count > 0) { int bytesRead = fileStream.Read(updateFileCache, offset, count); offset += bytesRead; count -= bytesRead; } } if (serverBundleIsZip) { byte[] zipMd5Bytes = MD5Utility.GetMd5Bytes(updateFileCache, 0, length); int zipMd5Code = BitConverter.ToInt32(zipMd5Bytes, 0); if (zipMd5Code != updateFileInfo.ZipMd5Code) { FileUtility.DeleteFile(filePath); return(false); } int decompressSize = ZipUtility.DeCompressionFileInSamePath(filePath, serverBundleZipPassword); if (decompressSize != updateFileInfo.Length) { FileUtility.DeleteFile(filePath); return(false); } } else { byte[] md5Bytes = MD5Utility.GetMd5Bytes(updateFileCache, 0, length); int md5Code = BitConverter.ToInt32(md5Bytes, 0); if (md5Code != updateFileInfo.Md5Code) { FileUtility.DeleteFile(filePath); return(false); } } string srcPath = PathUtility.GetCombinePath(AppConst.Path.HotUpdateDownloadDataPath, updateFileInfo.AssetBundleName); string desPath = PathUtility.GetCombinePath(AppConst.Path.PresistentDataPath, updateFileInfo.AssetBundleName); if (FileUtility.IsFileExist(desPath)) { FileUtility.DeleteFile(desPath); } FileUtility.Move(srcPath, desPath); if (FileUtility.IsFileExist(filePath)) { FileUtility.DeleteFile(filePath); } return(true); }