public static void BuildResIndex() { string resPath = Application.streamingAssetsPath + "/Android/"; ///----------------------创建文件列表----------------------- string newFilePath = Application.streamingAssetsPath + "/resIndex.txt"; if (File.Exists(newFilePath)) { File.Delete(newFilePath); } files = ZFileUtil.GetAllFiles(resPath); FileStream fs = new FileStream(newFilePath, FileMode.CreateNew); StreamWriter sw = new StreamWriter(fs); for (int i = 0; i < files.Count; i++) { string file = files[i]; string ext = Path.GetExtension(file); if (file.EndsWith(".meta") || file.Contains(".DS_Store")) { continue; } string md5 = Util.md5file(file); string value = file.Replace(resPath, string.Empty); sw.WriteLine(value + "|" + md5); } sw.Close(); fs.Close(); Debug.Log("生成resIndex完毕!"); }
/// <summary> /// 复制版本信息到对应的路径 /// </summary> /// <param name="path"></param> public static void CopyVersionInfoToTarget(string tarPath) { string sourcePath = Application.streamingAssetsPath; Directory.CreateDirectory(tarPath); List <string> files = ZFileUtil.GetAllFiles(sourcePath); //获取所有文件 //将文件移到对应目录 foreach (var file in files) { string fName = Path.GetFileName(file); //文件名 string pathComb = file.Replace(sourcePath, ""); string targetFolder = tarPath + "/" + Path.GetDirectoryName(file).Replace(sourcePath, ""); if (!Directory.Exists(targetFolder)) { Directory.CreateDirectory(targetFolder); } File.Copy(file, targetFolder + "/" + fName, true); } }