コード例 #1
0
    //加密
    static void EncryptAB(string pattern = "")
    {
        Directory.CreateDirectory(ABPATH);
        List <byte> result = new List <byte>();

        string[] files = Directory.GetFiles(ORIGINABPATH);
        for (int i = 0; i < files.Length; i++)
        {
            string path = files[i];
            if (path.Contains(".meta") || path.Contains(".manifest"))
            {
                continue;
            }
            string fileName = Path.GetFileNameWithoutExtension(path);
            if (string.IsNullOrEmpty(pattern) || fileName.Contains(pattern))
            {
                string destPath = ABPATH + "/" + fileName.GetHashCode() + Path.GetExtension(path);
                if (File.Exists(destPath))
                {
                    File.Delete(destPath);
                }

                if (ResMgr.IsEncrypt(fileName)) // 加密的文件
                {
                    result.Clear();
                    result.AddRange(headBytes);
                    result.AddRange(File.ReadAllBytes(path));
                    File.WriteAllBytes(destPath, result.ToArray());
                }
                else
                {
                    File.Copy(path, destPath);
                }
            }
        }
    }