文件压缩
下面是我压缩文件的代码,可是文件可以压缩了 ,但是为什么压缩的文件是 “WebSite3\\App_Data\\shenzhou.txt”而不是只压缩“shenzhou.txt”,请会的知道一下谢谢,下面我的代码哪里错了啊public static void Unzip()
{
ZipOutputStream zipStream = null;
FileStream streamWriter = null;
try
{
Crc32 crc32 = new Crc32();
zipStream = new ZipOutputStream(File.Create("D:\\WebSite3\\App_Data\\shenzhou1.zip"));
String file ="D:\\WebSite3\\App_Data\\shenzhou.txt";
streamWriter = File.OpenRead(file);
byte[] buffer = new byte[streamWriter.Length];
streamWriter.Read(buffer, 0, buffer.Length);
streamWriter.Close();
crc32.Reset();
crc32.Update(buffer);
ZipEntry zipEntry = new ZipEntry(file);
zipEntry.DateTime = DateTime.Now;
zipEntry.Size = buffer.Length;
zipEntry.Crc = crc32.Value;
zipStream.PutNextEntry(zipEntry);
zipStream.Write(buffer, 0, buffer.Length);
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (streamWriter != null)
{
streamWriter.Close();
}
if (zipStream != null)
{
zipStream.Finish();
zipStream.Close();
}
}
}
--------------------编程问答-------------------- 有人会吗? 帮忙吗
补充:.NET技术 , C#