NullRereferenceException when extracting
description
Hey Cheeso, I am getting a NullReferenceException when extracting. Here's the stackTrace
at Ionic.Zip.ZipEntry.InternalExtract(String baseDir, Stream outstream, String password) in C:\DotNetZip\v1.9.1.5\DotNetZip\Zip Partial DLL\ZipEntry.Extract.cs:line 602 at Ionic.Zip.ZipEntry.Extract(Stream stream) in C:\DotNetZip\v1.9.1.5\DotNetZip\Zip Partial DLL\ZipEntry.Extract.cs:line 112 at MyConsole.Program.Main(String[] args) in C:\NetTiers\SourceAnywhere\NoMoreConsole\Program.cs:line 34 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
And here's my code.
class Program{ static void Main(string[] args) { Item1 item = DataRepository.Provider.Item1Provider.Get(new Item1Key(33170)); FileInfo1 fileInfo = DataRepository.Provider.FileInfo1Provider.Get(new FileInfo1Key(item.BiFlInfoId));//Vss.GetFileBytes(47013); using (FileStream fileStream = File.Create(item.StrItnme)) { byte[] fileBytes = fileInfo.ImEfldat; byte[] fileBytes2 = fileInfo.ImFldat; MemoryStream memStream = new MemoryStream(); memStream.Write(fileBytes, 0, fileBytes.Length); memStream.Write(fileBytes2, 0, fileBytes2.Length); memStream.Seek(0, SeekOrigin.Begin); ZipInputStream zipInStream = new ZipInputStream(memStream); ZipEntry zipEntry = zipInStream.GetNextEntry(); zipEntry.Extract(fileStream); } }}
Am I doing anything really dumb and obvious to you? I am trying to take those bytes which contain compressed data, get the first file contained in the compressed bytes and then write the decompressed file to the fileStream.
It appears that
_container.ZipFile.Reset();
is failing in ZipEntry.Extract.cs