/// <summary> /// 解压文件并返回解压后的文件字节数组 /// </summary> /// <param name="path">要解压的文件完全路径 例如: D:/Eclipse/configuration/zzzz.gz </param> /// 此方法返回解压后的文件字节数组 /// <returns></returns> public static byte[] DecompressFile(string path) { string tempFilePath = System.IO.Path.GetDirectoryName(path); if (tempFilePath != "") //如果解析出来的目录路径不为空 { if (!Directory.Exists(tempFilePath)) //判断是否存在 { try { Directory.CreateDirectory(path);//创建新路径 } catch (Exception e) { Debug.LogError($"路径格式错误{e.Message}"); return(null); } } } else { Debug.LogError("路径格式错误"); return(null); } string str = TestGZip.ReadGzipFromFile(path); byte[] bytes = System.Text.Encoding.Default.GetBytes(str); return(bytes); }