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