mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-03 21:23:38 +00:00
I get a Value cannot be null error on some gzips but not others #348
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rickyelqasem on GitHub (Mar 19, 2019).
I get error: System.ArgumentNullException: 'Value cannot be null. Parameter name: path2' on some gzips but not others that are in the same directory when I try to extract them
string endTarget = @"d:\TestUEF";
string[] files2 = Directory.GetFiles(sourcePath);
foreach (string file in files2)
{
string filePath = @file;
using (Stream stream = File.OpenRead(filePath))
{
var reader = ReaderFactory.Open(stream);
while (reader.MoveToNextEntry())
{
if (!reader.Entry.IsDirectory)
{
reader.WriteEntryToDirectory(endTarget, new ExtractionOptions() { ExtractFullPath = true, Overwrite = true });
}
}
}
}
@adamhathcock commented on GitHub (Mar 20, 2019):
Stacktrace and version is needed
@rickyelqasem commented on GitHub (Mar 20, 2019):
Not working zip > https://bit.ly/2TPl9lm
Working zip > https://bit.ly/2TNCR8W
.net = 4.6.1
sharpcompress = Install-Package sharpcompress -Version 0.23.0
System.ArgumentNullException
HResult=0x80004003
Message=Value cannot be null.
Parameter name: path2
Source=mscorlib
StackTrace:
at System.IO.Path.Combine(String path1, String path2)
at SharpCompress.Common.ExtractionMethods.WriteEntryToDirectory(IEntry entry, String destinationDirectory, ExtractionOptions options, Action`2 write)
at SharpCompress.Readers.IReaderExtensions.WriteEntryToDirectory(IReader reader, String destinationDirectory, ExtractionOptions options)
at UEF_Extractor.Form1.extractUEFFilesToolStripMenuItem_Click(Object sender, EventArgs e) in D:\OneDrive\devwork\UEF Extractor\UEF Extractor\Form1.cs:line 84
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.MenuStrip.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at UEF_Extractor.Program.Main() in D:\OneDrive\devwork\UEF Extractor\UEF Extractor\Program.cs:line 19
@rickyelqasem commented on GitHub (Mar 20, 2019):
Its got something to do with the contents which is a file without the filename attribute so when I extract with winrar it gives the file the same name as the zip with the .zip extension.
@adamhathcock commented on GitHub (Mar 20, 2019):
Since that's the case, you should can handle it yourself.
The
WriteEntryToDirectorytype methods are extensions to make common scenarios easy but it doesn't handle everything. My intent isn't to have a fully fledged WinZip/WinRAR UI facing library but a more raw one that allows developers to do what they need to more easily. I've tried to avoid doing a lot of file-facing things.@rickyelqasem commented on GitHub (Mar 20, 2019):
I actually found an alternate going back to system.io.compress > https://stackoverflow.com/questions/24138373/unzip-gz-file-using-c-sharp < this is working for me now.
@Bond-009 commented on GitHub (Sep 21, 2021):
no-filename.gz
A test file for whoever wants to fix this and a test
@Rombersoft commented on GitHub (Jul 8, 2024):
I see this bug is not fixed yet. Version 0.37.2
@adamhathcock commented on GitHub (Jul 9, 2024):
You can fix it yourself and please add a test. My comment still stands about the convenience method and the ability to handle all entries the way you want to.
@henkgl commented on GitHub (Nov 12, 2024):
A workaround for this issue, which worked for me is the following:
Instead of using:
Use this: