当前位置:编程学习 > C#/ASP.NET >>

文件压缩

下面是我压缩文件的代码,可是文件可以压缩了 ,但是为什么压缩的文件是 “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#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,