码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2014-05-04 09:55:49      阅读:402      评论:0      收藏:0      [点我收藏+]

标签:blog   class   code   ext   get   int   

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;
 
            }

  

c#植物大战僵尸素材提取,布布扣,bubuko.com

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

标签:blog   class   code   ext   get   int   

原文地址:http://www.cnblogs.com/qq578023708/p/3705911.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!