标签: dotnetzip

ASP MVC下载Zip文件

我有一个视图,我把事件的ID,然后我可以下载该事件的所有图像.....这是我的代码

[HttpPost]
    public ActionResult Index(FormCollection All)
    {
        try
        {
            var context = new MyEntities();

            var Im = (from p in context.Event_Photos
                      where p.Event_Id == 1332
                      select p.Event_Photo);

            Response.Clear();

            var downloadFileName = string.Format("YourDownload-{0}.zip", DateTime.Now.ToString("yyyy-MM-dd-HH_mm_ss"));
            Response.ContentType = "application/zip";

            Response.AddHeader("content-disposition", "filename=" + downloadFileName);

            using (ZipFile zipFile = new ZipFile())
            {
                zipFile.AddDirectoryByName("Files");
                foreach (var userPicture in Im)
                {
                    zipFile.AddFile(Server.MapPath(@"\") + userPicture.Remove(0, 1), "Files");
                }
                zipFile.Save(Response.OutputStream);

                //Response.Close();
            }
            return View();
        }
        catch (Exception ex)
        {
            return View();
        }
    }
Run Code Online (Sandbox Code Playgroud)

问题是每次我得到html页面下载所以而不是下载"Album.zip"我得到"Album.html"任何想法???

asp.net-mvc dotnetzip

1
推荐指数
1
解决办法
1万
查看次数

有什么方法可以使用DotNetZip创建一个空文件夹吗?

我正在尝试使用DotNetZip在C#.NET中创建一个zip文件。但是,我确实需要不时包含空文件夹。这可能吗?有什么技巧可以实现吗?

.net zip dotnetzip

1
推荐指数
1
解决办法
1036
查看次数

DotNetZip真的使用WinZipAes256吗?

我正在使用dotnetzip创建一些带有一些AES密码的zip文件,例如:

 using (ZipFile zip = new ZipFile())
 {
       zip.Password = PASS;
       zip.Encryption = EncryptionAlgorithm.WinZipAes256;
       zip.AddFile("test.txt"); 
       zip.Save("test.zip");
 }
Run Code Online (Sandbox Code Playgroud)

在此之后,我注意到在没有指定算法的情况下读取文件没有问题

 using (ZipFile zip = ZipFile.Read("test.zip")
 {
       zip.Password = PASS;
       // zip.Encryption = EncryptionAlgorithm.WinZipAes256; 
       foreach (ZipEntry e in zip)
       {
           e.Extract(@"C:\tmp\");
       }
 }
Run Code Online (Sandbox Code Playgroud)

然后有些情况下提取产生了一些不可读的文件,但并非总是如此; 大部分时间都是完全可读的,没有指定算法.

现在基于他们的维基:

创建使用WinZip兼容的AES加密的Zip存档.由于担心
所有zip工具支持的标准密码保护功能都很薄弱,WinZip扩展了ZIP规范并添加了一种使用AES加密来保护Zip文件中条目的方法.

但不明白这是否真的是AES 256加密.

无论如何指定算法它只会提取可读文件,所以文件肯定是可读的,现在我关心的是安全性.

编辑 确保在解压缩之前指定密码算法,否则文件将无法读取!

c# security aes dotnetzip

1
推荐指数
1
解决办法
3383
查看次数

从受密码保护的Zip文件中提取

这是我的要求,我需要从受密码保护的压缩文件中提取文件.我想知道是否有任何代码片段可用.我正在使用SSIS从FTP下载这些压缩文件.是否有我可以使用的4.5框架的最新更新.

更新:

我现在已经引用了该文件并尝试了一个示例,但现在我得到了一个例外,我甚至尝试在我的脚本任务中添加一个断点,但我得到的只是一个例外.

例外:

   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
Run Code Online (Sandbox Code Playgroud)

快照: 在此输入图像描述

码:

try
    {
            string zipfilePath = @"C:\ZipFiles";
            string zipPassword = "qwerty";
        using (ZipFile zip = new ZipFile())
        {
            zip.Password = zipPassword;
            zip.AddFile("File-01.txt");
            zip.AddFile("File-02.txt");
            zip.AddFile("File-03.txt");
            zip.AddFile("File-04.txt");
            zip.Save(zipfilePath + "AllFiles.zip");
        } …
Run Code Online (Sandbox Code Playgroud)

c# ssis dotnetzip .net-4.5 script-task

1
推荐指数
1
解决办法
5093
查看次数

在 dotnetzip 中找到 ionic.zip.dll

当然我很笨,但我找不到 ionic.zip.dll

在他们的页面上,我点击了下载存档按钮。我已经解压了所有文件,但我看不到 dll。显然我做错了什么,但什么?

我已经搜索了该文件的文件夹,但没有返回任何内容

.net dotnetzip

1
推荐指数
1
解决办法
5900
查看次数

在C#中的Zip文件中创建一个文件

是否可以在Zip文件中创建文件?

假设我有一个文件,abc.zip并希望在其中创建一个名为的文件SomeFile.txt.可能吗?[我正在使用一个DLL Ionic.Zip,它有助于Zip文件操作].另外,我想在不解压缩的情况下这样做.

c# zip dotnetzip

0
推荐指数
1
解决办法
205
查看次数

DotNetZip - 添加文件夹

我想这很简单,但我在DotNetZip示例或文档中找不到任何帮助.我需要将文件夹添加到包含文件夹和文件的zip文件中,我需要维护文件夹而不是仅压缩文件,但使用以下文件总是剥离文件夹:

 using (ZipFile zip = new ZipFile())
                {
                    string[] files = Directory.GetFiles(@TempLoc);
                    string[] folders = Directory.GetDirectories(@TempLoc);
                    zip.AddFiles(files, "Traces");

                    foreach (string fol in folders)
                    {
                        zip.AddDirectory(fol, "Traces");
                    }

                    zip.Comment = "These traces were gathered " + System.DateTime.Now.ToString("G");
                    zip.Save(arcTraceLoc + userName.Text + "-Logs.zip");
                }
Run Code Online (Sandbox Code Playgroud)

我正在使用循环,因为我找不到类似于DotNetZip中的'AddFiles'的文件夹的功能.

谢谢.

c# compression dotnetzip

0
推荐指数
1
解决办法
3515
查看次数

如何在c#中使用dotnetzip检查文件是否受密码保护,用户传递的密码是否正确

在我的应用程序中,我使用DotNetZip来压缩和解压缩文件.在提取文件之前,我想知道提供的密码是否正确.现在我这样做.

foreach (var sourceFile in sourceFileNames) {
 ZipFile file = ZipFile.Read(sourceFile);
 foreach (ZipEntry entry in file.Entries) {
    if (FileSystem.Exists(conf.Target + entry.FileName)) {
       FileSystem.Delete(conf.Target + entry.FileName);
    }
    if (!string.IsNullOrEmpty(conf.Password)) {
       entry.Password = conf.Password;
    }
       entry.Extract(conf.Target);
 }
}
Run Code Online (Sandbox Code Playgroud)

这里'sourceFileNames'包含zip文件列表

如果密码错误或没有提供,那么它会给出错误,但我不想这样做.

我想要做的是首先检查每个zip文件的密码,如果所有zip文件都有正确的密码,那么只提取所有密码.

c# dotnetzip

0
推荐指数
1
解决办法
2686
查看次数

密码选项在Zip文件中不起作用

我正在使用DotNetZip库创建一个启用密码的zip文件,代码如下:

using (ZipFile zip = new ZipFile())
{
    string[] Files = Directory.GetFiles(cryptPath, "*.*");
    foreach (string f in Files)
    {
        zip.AddFile(f);                       
    }                   
    zip.Password = "mypassord";
    zip.Save(cryptPath + @"\output.zip");
}
Run Code Online (Sandbox Code Playgroud)

一切正常,但密码选项不起作用,打开文件时没有提示密码?我怎么能启用这个?

c# compression passwords zip dotnetzip

0
推荐指数
1
解决办法
1889
查看次数

错误无法在此范围内声明局部变量

我试图用DotNetZip解压缩文件,但我在"e"上收到错误

using (ZipFile zip = ZipFile.Read(openFileDialog1.FileName))
{
    foreach (ZipEntry e in zip)
    {
        e.Extract(Environment.CurrentDirectory, ExtractExistingFileAction.OverwriteSilently);
    }
}
Run Code Online (Sandbox Code Playgroud)

c# dotnetzip

-1
推荐指数
1
解决办法
2万
查看次数

使用DotNetZIP无法压缩超过10 GB的大文件

我能够压缩最多1 GB的文件夹,但我必须压缩超过10 GB.

 string filePath  = C:\Work; // path of the source file 
 private void compressFile(string filePath)
 {
     using (ZipFile zip = new ZipFile())
     {                    
        zip.AddDirectory(Path.Combine(filePath, "Demo"));
        if (File.Exists(Path.Combine(filePath, "Demo.zip")))
        {
           File.Delete(Path.Combine(filePath, "Demo.zip"));
           zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression;                
           zip.Save(Path.Combine(filePath, "Demo.zip"));                        
         }   

         zip.Save(Path.Combine(filePath, "Demo.zip"));               
       }      
    }
Run Code Online (Sandbox Code Playgroud)

c# dotnetzip

-1
推荐指数
1
解决办法
869
查看次数

标签 统计

dotnetzip ×11

c# ×8

zip ×3

.net ×2

compression ×2

.net-4.5 ×1

aes ×1

asp.net-mvc ×1

passwords ×1

script-task ×1

security ×1

ssis ×1