示例#1
0
        private static void ReplaceTargetToSourceWithASCII(string sourceFileFullName, string targetFileFullName, string sourceSkeletalMeshID, string targetSkeletalMeshID, string sourceMaterialInstanceConstant, string targetMaterialInstanceConstant, string sourceTexture2D, string targetTexture2D, string sourceObjectID, string targetObjectID)
        {
            FileInfo   fileInfo   = new FileInfo(targetFileFullName);
            FileStream fileStream = fileInfo.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None);

            byte[] numArray = new byte[checked ((int)fileStream.Length)];
            fileStream.Read(numArray, 0, (int)numArray.Length);
            numArray            = ReplaceClass.ReplaceWithByte(ref numArray, targetSkeletalMeshID, sourceSkeletalMeshID);
            numArray            = ReplaceClass.ReplaceWithByte(ref numArray, targetMaterialInstanceConstant, sourceMaterialInstanceConstant);
            numArray            = ReplaceClass.ReplaceWithByte(ref numArray, targetTexture2D, sourceTexture2D);
            numArray            = ReplaceClass.ReplaceWithByte(ref numArray, targetObjectID, sourceObjectID);
            fileStream.Position = 0L;
            fileStream.Write(numArray, 0, (int)numArray.Length);
            fileStream.Flush();
            fileStream.Close();
            string str = Path.Combine(Path.GetDirectoryName(targetFileFullName), Path.GetFileName(sourceFileFullName));

            fileInfo.MoveTo(str);
        }
示例#2
0
 internal static byte[] ReplaceWithByte(ref byte[] buffer, string source, string target)
 {
     byte[] bytes    = Encoding.ASCII.GetBytes(source);
     byte[] numArray = Encoding.ASCII.GetBytes(target);
     return(ReplaceClass.ReplaceWithByte(ref buffer, bytes, numArray));
 }
示例#3
0
        private static void Replace(string fileFullName, string sourceFileFullName, string sourceFileNameX, string sourceFileNameY, string sourceFileNameZ, string targetFileNameX, string targetFileNameY, string targetFileNameZ, string sourceObjectID, string targetObjectID)
        {
            string fileNameWithoutExtension = null;
            string str = null;
            string fileNameWithoutExtension1 = null;
            string str1 = null;
            string fileNameWithoutExtension2 = null;
            string str2 = null;

            if (!string.IsNullOrEmpty(sourceFileNameX))
            {
                fileNameWithoutExtension = Path.GetFileNameWithoutExtension(sourceFileNameX);
            }
            if (!string.IsNullOrEmpty(sourceFileNameY))
            {
                str = Path.GetFileNameWithoutExtension(sourceFileNameY);
            }
            if (!string.IsNullOrEmpty(sourceFileNameZ))
            {
                fileNameWithoutExtension1 = Path.GetFileNameWithoutExtension(sourceFileNameZ);
            }
            if (!string.IsNullOrEmpty(targetFileNameX))
            {
                str1 = Path.GetFileNameWithoutExtension(targetFileNameX);
            }
            if (!string.IsNullOrEmpty(targetFileNameY))
            {
                fileNameWithoutExtension2 = Path.GetFileNameWithoutExtension(targetFileNameY);
            }
            if (!string.IsNullOrEmpty(targetFileNameZ))
            {
                str2 = Path.GetFileNameWithoutExtension(targetFileNameZ);
            }
            FileInfo   fileInfo   = new FileInfo(fileFullName);
            FileStream fileStream = fileInfo.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None);

            byte[] numArray = new byte[checked ((int)fileStream.Length)];
            //byte[] numArray = new byte[fileStream.Length];
            fileStream.Read(numArray, 0, (int)numArray.Length);
            if ((fileNameWithoutExtension == null ? false : str1 != null))
            {
                numArray = ReplaceClass.ReplaceWithByte(ref numArray, str1, fileNameWithoutExtension);
            }
            if ((str == null ? false : fileNameWithoutExtension2 != null))
            {
                numArray = ReplaceClass.ReplaceWithByte(ref numArray, fileNameWithoutExtension2, str);
            }
            if ((fileNameWithoutExtension1 == null ? false : str2 != null))
            {
                numArray = ReplaceClass.ReplaceWithByte(ref numArray, str2, fileNameWithoutExtension1);
            }
            if ((sourceObjectID == null ? false : targetObjectID != null))
            {
                numArray = ReplaceClass.ReplaceWithByte(ref numArray, targetObjectID, sourceObjectID);
            }
            fileStream.Position = 0L;
            fileStream.Write(numArray, 0, (int)numArray.Length);
            fileStream.Flush();
            fileStream.Close();
            string str3 = Path.Combine(Path.GetDirectoryName(fileFullName), Path.GetFileName(sourceFileFullName));

            fileInfo.MoveTo(str3);
        }