Hi,
I'm encoutering the following error
System.NullReferenceException: 'Object reference not set to an instance of an object.'
when I try to extract an .exe from a RAR archive.
Here is the RAR in question: https://sourceforge.net/projects/cdrtfe/files/tools/binaries/cdrtools/cdrtools-3.02a10-bin-win32-patched.rar/download
I am trying to extract the file mkisofs.exe from the archive, but consistenly get the above error.
Here is my code:
public static string MkisofsPath => Path.Combine(Application.StartupPath, "External", "mkisofs", "mkisofs.exe");
[...]
using (var archive = RarArchive.OpenArchive(rarPath))
{
foreach (var entry in archive.Entries)
{
if (
!entry.IsDirectory &&
entry.Key.EndsWith("mkisofs.exe", StringComparison.OrdinalIgnoreCase)
)
{
Directory.CreateDirectory(Path.GetDirectoryName(MkisofsPath)!);
using (var outStream = File.Create(MkisofsPath))
{
// System.NullReferenceException on this line:
entry.WriteTo(outStream);
}
// 3. Cleanup
try { File.Delete(rarPath); } catch { }
return;
}
}
throw new FileNotFoundException("mkisofs.exe not found in archive");
I also get the error when using entry.WriteToFile or entry.WriteToFileAsync.
Attached is an image of the Rar's properties and contents in 7zip.
Information
System OS: Windows 11 25H2
SharpCompresss Nuget version: 0.49.1
Project: Windows Forms Application (.NET 10.0)
Any help would be greatly appreciated!
Hi,
I'm encoutering the following error
System.NullReferenceException: 'Object reference not set to an instance of an object.'when I try to extract an .exe from a RAR archive.
Here is the RAR in question: https://sourceforge.net/projects/cdrtfe/files/tools/binaries/cdrtools/cdrtools-3.02a10-bin-win32-patched.rar/download
I am trying to extract the file mkisofs.exe from the archive, but consistenly get the above error.
Here is my code:
I also get the error when using entry.WriteToFile or entry.WriteToFileAsync.
Attached is an image of the Rar's properties and contents in 7zip.
Information
System OS: Windows 11 25H2
SharpCompresss Nuget version: 0.49.1
Project: Windows Forms Application (.NET 10.0)
Any help would be greatly appreciated!