带有DotnetZip库的Zip文件,没有子foldfer。 [英] Zip file with DotnetZip library wihout sub foldfer.

查看:121
本文介绍了带有DotnetZip库的Zip文件,没有子foldfer。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,



我目前正在使用带有VS 2010的Dotnet 4.0 ..

我想用zip文件测试DotnetZip库。



以下是我的编码:

Dear all,

I''m currently using Dotnet 4.0 with VS 2010..
I want to test zip file using DotnetZip library.

this following is my coding :

using Ionic.Zip;

namespace testzip
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {           
            using (ZipFile zip = new ZipFile())
            {
                string inputdirectory = @"D:\BackUp\20130102.bak";
                string outputdirectory = @"D:\BackUp\20130102.ZIP";
                inputdirectory = inputdirectory.Replace("\\", "\\\\");
                outputdirectory = outputdirectory.Replace("\\", "\\\\");
                DirectoryInfo di = new DirectoryInfo(inputdirectory);
                zip.AddFile(inputdirectory);
                //zip.AddDirectory(inputdirectory, "ZipTest");
                zip.Comment = "This zip file is created using DotNetZip library";
                zip.Save(outputdirectory);
            }
        }



此代码工作正常...我可以成功压缩我的文件名20130102.bak,但是当我使用Winzip或winrar提取 - >然后在这里选择提取 - >它不仅提取我的文件,还包括子文件夹名称BackUp。

我想压缩和提取没有子文件夹,请帮助我...


this code is working fine... I can zip my file name 20130102.bak successfully, but when i use Winzip or winrar to extract -> then choose extract here-> it not only extract my file, but also include sub folder name BackUp.
I want to zip and extract without sub folder, Please help me...

推荐答案

这是winzip的设置,它与你的代码无关。
This is a setting for winzip, it has nothing to do with your code.


亲爱的基督徒,



感谢您的快速回复...

但我想知道如果我使用winzip或winrar压缩其他文件,例如文件名123.bak。然后我使用winzip来提取这里包括子文件夹。它只给我这个文件。

例如:1 /我的文件名是123.bak - >用winzip压缩后这个 - >文件名是123.zip

2 /使用winzip - >这里提取 - > 123.back



这就是为什么我认为它不是winzip设置问题。
Dear Christian,

Thank for your quick reply...
But i wonder that if i use winzip or winrar to zip other file, for example file name 123.bak .Then i use winzip to extract here it not include sub folder. it give me only this file.
Ex : 1/ my file name is 123.bak--> after zip this with winzip -->file name is 123.zip
2/ use winzip--> extract here --> 123.back

That why i think it not winzip setting problem.


这篇关于带有DotnetZip库的Zip文件,没有子foldfer。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆