Quantcast
Channel: DotNetZip Library
Viewing all 664 articles
Browse latest View live

New Post: Classic ASP and .xlsx report

$
0
0
Hi All, im new here and I just want to ask if someone has a good example of how to create an excel report using classic asp code and save it as .xlsx format. At this point i can generate .xls files but now I want to create the same report but in .xlsx format.

Is this possible using DotNetZip??

Thanks in advance.

New Post: "Bad CRC32 in GZIP trailer" error if I don't read the whole stream

$
0
0
I found some time to dig into this.

Looking at the .Net version there is some CRC32 checking (see GZipDecoder.ReadFooter and Inflator.Decode if you have Reflector or equivalent). However that code only appear to be called as the stream is read and it gets to the end. However GZipStream doesn't override Close or Dispose so no checks are done when you do that.

The code in DotNetZip that says //read to end of file is not doing that at all. The checksum needs 8 bytes so if there's less than 8 bytes in the buffer it reads enough bytes of the next block so that it has 8 bytes.

My workaround for this is that I've pulled the DotNetZip source into my code and modified Close such that it takes a bool that allows me to disable the CRC check.

This is a tough one to 'fix'. Its clearly much safer to to the checksum but it would mean adding code to read the whole file apart from the last 8 bytes - I was unable to work out how to do this safely in my experiments. On a big file this could be expensive which makes it slower then the .Net version AND a different behavior in this scenario.

Created Unassigned: Filename changed for unusual character [16242]

$
0
0
The filename of an Added file changes to a different one within the zipfile, I found the case below but I'm guessing the issue is for other characters as well. Using Version 1.9.1.8, RuntimeVersion v2.0.50727.

Code to repeat:
```
ZipFile z = new ZipFile();
z.AddFile(@"C:\temp\–.pdf");
z.Save(@"c:\temp\out.zip");
```

This might be a dupe, but I am not sure for which issue.

Commented Unassigned: Filename changed for unusual character [16242]

$
0
0
The filename of an Added file changes to a different one within the zipfile, I found the case below but I'm guessing the issue is for other characters as well. Using Version 1.9.1.8, RuntimeVersion v2.0.50727.

Code to repeat:
```
ZipFile z = new ZipFile();
z.AddFile(@"C:\temp\–.pdf");
z.Save(@"c:\temp\out.zip");
```

This might be a dupe, but I am not sure for which issue.
Comments: ** Comment from web user: Nenotlep **

The character '–' changes to a regular hyphen '-'.

Created Unassigned: Dont work with .VTF [16244]

$
0
0
Have out of range expection with .VTF(Valve Texture) files.

Commented Unassigned: Dont work with .VTF [16244]

$
0
0
Have out of range expection with .VTF(Valve Texture) files.
Comments: ** Comment from web user: phantom96 **

Sorry, with 1.9.18 binaries works fine.

Commented Issue: ZipFile.AddFile fails depending of the file size. [14087]

$
0
0
AddFile truncate the entry, and Extract trow an exception "bad read of entry test/MyFile.txt from compressed archive."
 
Debugging step by step sometimes work fine.
 
My code:
 
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim str As New String(" "c, 2490368)
IO.File.WriteAllText("C:\test\MyFile.txt", str)
End Sub
 
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Using zip As New Ionic.Zip.ZipFile
zip.AddFile("C:\test\MyFile.txt")
zip.Save("C:\test\MyZip.zip")
End Using
End Sub
 
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Using zip As Ionic.Zip.ZipFile = Ionic.Zip.ZipFile.Read("C:\test\MyZip.zip")
For Each arch As Ionic.Zip.ZipEntry In zip
arch.Extract("C:\test\opened")
Next
End Using
End Sub
Comments: ** Comment from web user: mlavoie88 **

I also just encountered this issue. Easy to work around with the ParallelDeflate setting, but difficult to isolate the failure since it occurs only on files of a specific size. I concur with earlier comments that the impact of this bug should be higher.

Commented Issue: BZip2InputStream.Read returns -1 instead of 0 [16069]

$
0
0
According to documentation on Stream class, the Read method should return 0 if the end of the stream has been reached, and there's no single mention of -1 possibility. But BZip2InputStream returns -1 if EOF is encountered.

This breaks some code relying on 0 as the EOF. I believe that Stream.CopyTo(...) will break as it checks for 0 as EOF.
Comments: ** Comment from web user: meddingt **

This should have a higher impact than low. This has a large affect on any implementation assuming correct behavior, or supporting different base stream types.


Commented Issue: BZip2InputStream.Read returns -1 instead of 0 [16069]

$
0
0
According to documentation on Stream class, the Read method should return 0 if the end of the stream has been reached, and there's no single mention of -1 possibility. But BZip2InputStream returns -1 if EOF is encountered.

This breaks some code relying on 0 as the EOF. I believe that Stream.CopyTo(...) will break as it checks for 0 as EOF.
Comments: ** Comment from web user: meddingt **

return (destOffset == offset) ? -1 : (destOffset - offset);

Created Unassigned: System.ObjectDisposedException: Cannot access a closed file [16254]

$
0
0
I have this code:

```
Using zip As ZipFile = New ZipFile()
zip.UseZip64WhenSaving = Zip64Option.AsNecessary
If (tamMaxFichero IsNot Nothing) Then
zip.MaxOutputSegmentSize = tamMaxFichero
End If

zip.UpdateDirectory(rutaDirectorio)
If (exclusiones IsNot Nothing) Then
Dim entradas As List(Of Ionic.Zip.ZipEntry)
For Each exclusion In exclusiones
entradas = zip.Entries.Where(Function(f) f.FileName.ToUpper().Contains(exclusion.ToUpper())).ToList()
For Each entrada In entradas
zip.RemoveEntry(entrada)
Next
Next
End If

zip.CompressionLevel = nivelCompresion
zip.Save(ficheroSalida)
End Using
```
Sometimes (not always) I get a System.ObjectDisposedException exception. Anyone can help me or tell me what is happening. Any solution to this?

Thanks in advance

New Post: "Garbage" files in directory crashing DotNetLib

$
0
0
Hi,

I'm trying to use DotNetZip to zip directories for back-up. I'm using the following script, based heavily one I found in the PowerShell examples.

[System.Reflection.Assembly]::LoadFrom('c:\Users\Walter\Documents\WindowsPowerShell\Modules\WalterMetcalf\DotNetZip\Ionic.Zip.dll');

$directoryToZip = 'c:\Users\Walter\Documents\';
$zipfile = new-object Ionic.Zip.ZipFile;
$e= $zipfile.AddEntry("Readme.txt", "This is a zipfile created from within powershell.");
$e= $zipfile.AddDirectory($directoryToZip, "home");
$zipfile.Save("D:\ZipFiles-ps1-out.zip");
$zipfile.Dispose();
` The script give a "Access denied" exception error on a file called TV_Music.ini, supposedly in a sub-directory which doesn't contain it--UNTiL you turn on "Display Hidden Files" in Windows Explorer! During my testing I have had the exception occur on other files, which apparently don't exist.
I'm guessing these files are re-parse items, but turning off (=FALSE) the "WillTraverseReparsePoints" property only make the problem worse.

Any ideas, suggestions?

Thanks,
Walter

P.S. I'm using update 1.9.1.8 of the library; PS 3.0 on Windows 7 SP1

New Post: Top-level folder not appearing as ZipEntry within zip file

$
0
0
I'm seeing some odd behavior when I try to read a zip file and enumerate the contents. I'm using Visual Basic 10 on Windows 7, and Ionic.Zip.Reduced.dll version 1.9.1.8.

Basically DNZ doesn't recognize folders in the top level of the zip file. It recognizes the files within them, and also the subfolders within them and the files within those subfolders.

Say I have file TopLevelZip.zip structured like this:

File1 at the top level
File2 at the top level
FolderA at the top level containing
File3
File4
FolderB at the top level containing
FolderB2 at the next level containing
  - File5
Running this VB code:
  Using zip1 As ZipFile = ZipFile.Read(ZipToUnpack)
    Dim e As ZipEntry
    For Each e In zip1
      Debug.Print(e.Info)
    Next
  End Using
will return info on all five files, and FolderB2; but not FolderA or FolderB.
I would like to return as a ZipEntry each of those two missing folders at the top level, as well as what presently appears.
Any ideas?

Commented Issue: DotNetZip should be kinder when throwing PathTooLongException [14035]

$
0
0
from http://dotnetzip.codeplex.com/discussions/267600
 
I encountered the System.IO.PathTooLongException, using ZipFile.AddDirectory() to save a zip. Problem here, the resulting exception doesn't even say which path was too long . Using the DotNetZip devkit I saw this happened in ZipEntry.Create when File (Directory) will be first accessed with File.GetLastWriteTime(filename) (ZipEntry.cs line 2402).
 
The path really was too long. A subdirectory of the directory I wanted to zip had a path longer than 259 characters (267 :) ), apparently the maximum path length the .NET IO system can handle. So the error was due to the .net limit. I found a nice blog post about this and how to use Win32 to access file/folders with >260 path length. http://blogs.msdn.com/b/bclteam/archive/2007/02/13/long-paths-in-net-part-1-of-3-kim-hamilton.aspx
 
If you zip such a directory, the whole process fails. What really bothered me was to find out which file/directory was too long, because the PathTooLongException doesn't return the path value. So it would be nice if you would catch this PathTooLongException and return a custom exception that tells u the path.
Comments: ** Comment from web user: franklo **

Long path tool is the best solution for your problem. try it and solve your problem.

Created Unassigned: DEFLATE64 Support [16275]

$
0
0
Are there plans to implement DEFLATE64?
I know there was discussion a few years ago regarding implementing this compression method.

New Post: Zipx

$
0
0
Hello. Was zipx ever added to DotNetZip? The only post I can find was from last year and the capability had not yet been added.

Thanks.

Kimberly

New Post: Top-level folder not appearing as ZipEntry within zip file

$
0
0
I ran into the same issue, and it appears to be related to how Windows creates zip files. I took a known-working zip file that I'd previously parsed correctly (ie top-level folders were listed as a ZipEntry), extracted it and re-zipped using Windows' own compression tool. On trying to parse this file, there were no top-level directories listed as a ZipEntry. Re-zipping the same folder with WinRar again gave me a correctly-parseable archive.

New Post: Top-level folder not appearing as ZipEntry within zip file

$
0
0
Thanks! Yes, I think you are right. I found a workaround, which is to extract everything to a temporary folder and traverse that (recursively, in case there are any zip files at a lower level). In some cases that might be a burden, but in this one it works well since I may need to open the lower levels.

Reviewed: v1.9.1.8 DotNetZip - Latest Stable (Jun 27, 2013)

$
0
0
Rated 5 Stars (out of 5) - This library is incredibly easy to use! I have been learning C# while working on a project at work. I struggled through generating Excel reports and finding the right library and commands to read from a database, but this open-source non-Microsoft library has made preparing the reports for delivery the easiest part.

New Post: Ionic.Zip.dll

$
0
0
I use Delphi Embarcadero XE2 (Rad Studio)
I import Ionic.Zip.dll and it's generate Ionic_Zip_TLB in my project
But only constructor of this Ionic Zip library could be use..


Does Ionic.Zip.dll work with Delphi environment?

New Post: Issue with Ionic.Zip in chrome or firefox

$
0
0
Hi,

I have asp.net c# code which, on click, creates a zip file including some excel files generated on the fly.

The code works fine in Internet Explorer, the zip file is downloadable and the files inside open correctly.

However when i click the button in Chrome or firefox, there is no luck and all that happens is that the page refreshs with the letters PK at the top.

any help?

below is an exerpt of what is happening;
using (ZipFile zipFile = new ZipFile())
            {
                foreach (var lll in List)
                {
                    Class currentClass = DBMLManager.Instance.ABC(lll.ID);

                    if (currentClass.Type == "THIS_TYPE")
                    {
                        List<uspProcClass> Details = Manager.Instance.Report(ID, lll.ID);

                        if (Details.Count > 0)
                        {
                            string fileName = "Report.pdf";
                            MemoryStream myMemoryStream = new MemoryStream();
                            MemoryStream newMemoryStream = Invoice.GenerateInvoiceForZip(lll.ID, myMemoryStream);
                            byte[] docDat = newMemoryStream.ToArray();

                            HttpContext.Current.Response.Clear();
                            HttpContext.Current.Response.ContentType = "application/PDF";
                            HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename=testdoc.pdf"));

                            zipFile.AddEntry(fileName, docDat);
                            Response.ClearContent();
                            Response.ClearHeaders();
                            Response.AppendHeader("content-disposition", "attachment; filename=" + zipName + ".zip");
                        }
                    }                    
                }

                zipFile.Save(Response.OutputStream);
                HttpContext.Current.Response.End();
            }
Thanks

Churni
Viewing all 664 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>