c# 解压缩问题
随波流的浪 2010-01-03 11:19:56 Unexpected EOF
public class UnZipClass
{
public static void UnZip(string FileToUpZip, string ZipedFolder, string Password)
{
if (!File.Exists(FileToUpZip))
return;
if (!Directory.Exists(ZipedFolder))
Directory.CreateDirectory(ZipedFolder);
using (ZipInputStream s = new ZipInputStream(File.OpenRead(FileToUpZip)))
{
if (!string.IsNullOrEmpty(Password.Trim()))
s.Password = Password.Trim();
ZipEntry theEntry;
int size = 2048;
long fszie;
int byteLenght;
String directoryPath = null ;
String filePath = null;
while ((theEntry = s.GetNextEntry()) != null)
{
//System.Windows.Forms.MessageBox.Show(s.Length.ToString());
//Console.WriteLine(theEntry.Name);
directoryPath = ZipedFolder;
string directoryName = Path.GetDirectoryName(theEntry.Name);
string fileName = Path.GetFileName(theEntry.Name);
directoryPath += "\\" + directoryName;
// create directory
if (directoryName.Length > 0)
{
Directory.CreateDirectory(directoryPath);
}
if (fileName != String.Empty)
{
fszie = theEntry.Size;
filePath = directoryPath + "\\" + fileName;
using (FileStream streamWriter = File.Create(filePath))
{
while (fszie > 0)
{
if (fszie > (long)size)
byteLenght = size;
else
byteLenght = Convert.ToInt32(fszie);
fszie = fszie - size;
byte[] data = new byte[byteLenght];
s.Read(data, 0, byteLenght);
streamWriter.Write(data, 0, byteLenght);
}
}
}
}
}
}
public static void UnZip(string FileToUpZip, string ZipedFolder)
{
UnZip(FileToUpZip, ZipedFolder, "");
}
#endregion
}
在 while ((theEntry = s.GetNextEntry()) != null)的地方 s.GetNextEntry()) 会抛出 Unexpected EOF 请问这个问题如何解决