首页 > 代码库 > c#植物大战僵尸素材提取

c#植物大战僵尸素材提取

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
string path = textBox1.Text;
            FileStream fs = File.OpenRead(path);
            byte[] bytes = new byte[fs.Length];
            fs.Read(bytes, 0, bytes.Length);
            fs.Close();
            for (int i = 0; i < bytes.Length; i++)
            {
                bytes[i] = (byte)(bytes[i] ^ 0xF7);
            }
            int i2 = 9;
            int endTag;
            List<mFileInfo> files = new List<mFileInfo>();
            do
            {
                int fileNameLength = bytes[i2];
                i2++;
                string fileName = Encoding.ASCII.GetString(bytes, i2, fileNameLength);
                i2 += fileNameLength;
                int fileLength = BitConverter.ToInt32(bytes, i2);
                i2 += 4;
                string unKnow = Encoding.ASCII.GetString(bytes, i2, 8);
                i2 += 8;
                endTag = bytes[i2];
                Debug.Print("length:{0} name:{1} fileLength:{2} endTag{3}", fileNameLength, fileName, fileLength, endTag);
                i2++;
                files.Add(new mFileInfo() { mfileName = fileName, mfileSize = fileLength });
            } while (endTag == 0);
            string mainPath = textBox2.Text;
            progressBar1.Maximum = files.Count;
            foreach (mFileInfo mfInfo in files)
            {
                progressBar1.Value++;
                string[] strings = mfInfo.mfileName.Split(‘\\‘);
                string tempPath = mainPath;
                if (strings.Length > 1)
                {
                    for (int i3 = 0; i3 < strings.Length - 1; i3++)
                    {
                        if (!Directory.Exists(tempPath + strings[i3]))
                        {
                            Directory.CreateDirectory(tempPath + strings[i3]);
                        }
                        tempPath += strings[i3] + "\\";
                    }
                }
                FileStream fs2 = new FileStream(mainPath + mfInfo.mfileName, FileMode.Create);
                fs2.Write(bytes, i2, mfInfo.mfileSize);
                fs2.Flush();
                fs2.Close();
                i2 += mfInfo.mfileSize;
 
            }