Created Unassigned: AES encryption is not FIPS compliant [17727]
New Post: Not able to save the zip file
Find a below simple code which i am trying to execute.
using (ZipFile zip = new ZipFile())
{
zip.AddFile("D:\Packages\Test.png");
zip.Save("D:\Athar\Myfile.zip");
}
I am getting an error @ zip.Save function and the issue is as below
"Access to the path 'D:\Athar\DotNetZip-e4gamapf.tmp' is denied."
Can you please let me know what am i missing to get this working fine.
Thanks and Regards,
Mohammed Athar.
New Post: How can I password protect the whole .zip file and not each file
I have been working with this class on many C# projects.
But for my current project, I would like to have a password only on main say sample.zip file.
Not on each zip within this sample.zip file, since it would not be a good user experience to have to input the same password or different one on each file with the sample.zip file.
My current testing code.
using (ZipFile zip = new ZipFile())
{
zip.Password = "123456!";
zip.AddFile(@"C:\Temp\ReadMe.txt"); // no password for this one
zip.AddFile(@"C:\Temp\image1.jpg");
zip.AddFile(@"C:\Temp\Installme.msi");
zip.Save("Backup.zip");
So, when you unzip this file, you can see each file, but if you want to read, edit, you will be prompted for the password.I would like you to have to enter the password once and then have access to any file.
Thanks,
New Post: C# .NET How can I add individual items one by one to a .zip file using DotNetZip?
Here's how I wrote them with FileStream/BinaryWriter:
private void WriteToBinary(string filepath)
{
FileStream fs = new FileStream(filepath, FileMode.Create, FileAccess.Write);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(SomeString);
bw.Write(SomeInteger);
bw.Write(SomeBoolean);
bw.Write.(SomeJPGImageInBase64String();
bw.Write(SomeMP3InBase64);
fs.Close();
bw.Close();
}
Now here's what I'd like to do: private void ZipItAll(string filepath)
{
Create a new instance of Ionic.Zip or some other zip method;
Add SomeString to it;
Add SomeInteger to it;
Add SomeBoolean to it;
Add SomeJPGImageInBase64String to it;
Add SomeMP3InBase64String to it;
Write the whole thing to a .zip file;
Call it a day;
}
Does DotNetZip have functionality to support the step-by-step outlined in ZipItAll()? I want to add individual items one by one and then save the whole thing to a .zip file. The only code examples I can find are where whole files are added one by one instead of individual items.Created Unassigned: Bad signature (0x6F9E597E) at position 0x00AF8F62 [17733]
https://www.dropbox.com/s/k8my8amsunxl6m7/Erste%20Schritte%20mit%20Dropbox.pdf?dl=0
Can anybody help me?
my code for extracting:
byte[] buffer = new byte[2048];
int n;
using (var raw = File.Open(zipFilePath, FileMode.Open, FileAccess.Read))
{
using (var input = new ZipInputStream(raw))
{
if (!string.IsNullOrEmpty(password))
input.Password = password;
ZipEntry entry;
while ((entry = input.GetNextEntry()) != null)
{
if (entry.IsDirectory) continue;
string outputPath = Path.Combine(targetPath, entry.FileName.Split(new []{ '/'}).Last());
using (var output = File.Open(outputPath, FileMode.Create, FileAccess.ReadWrite))
{
while ((n = input.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, n);
}
}
}
}
}
Created Unassigned: Hangs on zipfile.save method [17735]
ZipFile zFile = new ZipFile();
zFile.UseZip64WhenSaving = Zip64Option.AsNecessary;
zFile.AddDirectory(folderPath);
zFile.Save(zipFileName);
It gets stuck on save method.
Please suggest the solution.
Created Unassigned: Support for Mac via Mono [17745]
I have now ported the app to Apple Mac, by using the Mono framework to be the shim between the .net code and native Mac. The app works, but DotNetZip no longer unzips the zip file. I was getting an exception thrown by the call to Directory.CreateDirectory from the ZipEntry.InternalExtract method, exception error message "path is empty". Even though I can see the path being passed in is non-empty, it is something like "/Users/PaulF/.config/testfolder".
I looked at and modded the source code a bit to get it to work. Namely, the ZipEntry.Extract.cs file, ValidateOutput method. I get the OS platform, and if it's MACOSX or Unix, I avoid messing with the path in a couple of places (see attachment).
This change seems to be sufficient for my needs; but I was wondering if you had any thoughts about the code change? do I need to put any disclaimer into the modified version of the dll if I want to distribute it for my Mac app ?
New Post: Not able to extract files in my zip folder!
I tested it sevreal times and it deffently works when i haven't downloaded it, do u guys kno why?
Thanks
New Post: Password not working
Why does the following code not work?
The file gets created OK but it can be opened without a password...
Dim zf As New ZipFile
zf.AddFile("c:\users\public\test.pdf", "")
zf.Password = "whatever"
zf.Save("c:\users\public\test.zip")
ThanksNew Post: Not able to save the zip file
The way you have written your code will cause it to try to maintain the directory names also.
.Save can have a second parameter which is the path within the generated .zip file.
Set it to an empty string to add the files without a directory.
Hope this helps.
Created Unassigned: Compression per Entry [17757]
System.IO.Compression.ZipArchive allows compression per entry. This can make the zip creation process much faster if the file types are known. For example when dynamically creating a download bundle for an app update via a RESTFul web service it is common to create a zip with many pngs added using System.IO.Compression.CompressionLevel.NoCompression and a single large xml file that can be added with System.IO.Compression.CompressionLevel.Optimal.
Reviewed: v1.9.1.8 DotNetZip - Latest Stable (Mar 21, 2017)
New Post: Create ZIP from stream
public Class Record {
public string name { get; set; }
public string surname { get; set; }
}
List<Record> lst = new List<Record>();
I would like to iterate over this list and adding each record to the zip file. I do not want to create a txt file containing all these records (a record by line) and then once file saved on disk, create the zip file from that file, I mean, I do not want to create an intermediate file on disk in order to create the zip file from that.
How can I do this?
New Post: Error in create zip file
when I create a zip file from a folder with this code:
int segmentsCreated = 5;
using (ZipFile zip = new ZipFile())
{
zip.UseUnicodeAsNecessary = true; // utf-8
zip.AddDirectory(@"Desktop");
zip.Comment = "This zip was created at " + System.DateTime.Now.ToString("G");
zip.MaxOutputSegmentSize = 100 * 1024; // 100k segments
zip.Save("Nuovo.zip");
segmentsCreated = zip.NumberOfSegmentsForMostRecentSave;
}
It returns, to click on the new store, the following error message:the archive or is damaged or is in an unknown format (in Italian "Archive or is corrupt or in an unknown format").
What am I doing wrong? Graziee
Created Unassigned: Can't delete split zipfiles after extraction [17763]
When I try to delete the *.zip, it doesn't work, because the file is still in use by the application.
--- Code ----
Using oZip As ZipFile = ZipFile.Read(f)
Dim a As New ZipEntry
For Each a In oZip
sOriginalName = a.FileName
a.Extract(sDestinationPath, ExtractExistingFileAction.OverwriteSilently)
Next
End Using
...
For Each s In lstToDelete
If s.Contains(sFilename.Substring(0, sFilename.Length - 3)) Then
File.Delete(s)
End If
Next
New Comment on "Documentation"
New Post: Zipfile.Save() method crashes when called from my script
Exception calling "Save" with "1" argument(s): "C:\Users\cameron\FTP.log"
At line:28 char:1
+ $zipFile.Save("e:\temp\logs\test.zip")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FileNotFoundException
I had a quick look through the source code, and can't see anywhere where it's picking up the user folder, so no idea where it's getting that from. Commented Issue: name clash possible with temporary file during extraction [14097]
Suppose I have a zip file which contains: helloworld.txt test.txt
Now suppose I try to extract this zipfile into a directory, c:\Test . What happens is, for each file in the zipfile the library creates a filename.ext.tmp while he unpacks the specific file of the ze.Extract. That means, when it extracts helloworld.txt on ze.Extract(...); in the folder c:\test\ there will be a file called helloworld.txt.tmp till extract finishes.
A problem occurs when C:\test already has a file called helloworld.txt.tmp . If that happens, the library just fails with a message stating that the file already exists (the helloworld.txt.tmp, not the helloworld.txt).
Comments: ** Comment from web user: dwstark **
The way the code is written, it can completely fail to extract to an empty directory if the zip archive as created contains adjacent files:
x.txt
x.txt.tmp
The failure occurs if x.txt.tmp is extracted first (not just a hypothetical scenario, hence I am commenting here). Then when x.txt is to be extracted, x.txt.tmp already exists and the code throws on ZipEntry.Extract.cs line 770:
output = new FileStream(targetFileName, FileMode.CreateNew);
Instead of a simple "add .tmp on the end" to get a temporary file name, something less "Cheesy" is required. (Sorry.)
Seems like the inability to extract files with the above pattern would warrant a higher impact than 'Low'.
Patch Uploaded: #18779
dwstark has uploaded a patch.
Description:
Fix for 14097 against 1.9.1.8 release.
Commented Issue: name clash possible with temporary file during extraction [14097]
Suppose I have a zip file which contains: helloworld.txt test.txt
Now suppose I try to extract this zipfile into a directory, c:\Test . What happens is, for each file in the zipfile the library creates a filename.ext.tmp while he unpacks the specific file of the ze.Extract. That means, when it extracts helloworld.txt on ze.Extract(...); in the folder c:\test\ there will be a file called helloworld.txt.tmp till extract finishes.
A problem occurs when C:\test already has a file called helloworld.txt.tmp . If that happens, the library just fails with a message stating that the file already exists (the helloworld.txt.tmp, not the helloworld.txt).
Comments: ** Comment from web user: dwstark **
OK. Totally missed that this project moved to github. https://github.com/haf/DotNetZip.Semverd