SharpZipLib: Getting error "Index was outside the bounds of the array" when writing uncompressed data

Steps to reproduce

  1. Have a .txt.bz2 file that has more header columns than actual values Example: | first_name | last_name | middle_name | | John | Jones | |

Expected behavior

When running BZip2.Decompress(fileToDecompressAsStream, decompressedStream, true);, it should obviously be writing the data from the .bz2 file to the .txt file.

Actual behavior

I’m getting an error stating Index was outside the bounds of the array

I know that this issue is more of a “bad data” problem, rather than a problem with SharpZipLib. However, I was hoping you could help with finding a solution. Ideally, I would like to decompress the .bz2 file, and either remove the extra header column or give all the rows a NULL value. But I can’t find a way to do this. Any help you could provide would be very much appreciated!

Version of SharpZipLib

1.2.0

Obtained from (only keep the relevant lines)

  • Package installed using NuGet

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (9 by maintainers)

Most upvoted comments

Sorry I’m a little late getting back to the conversation. Thank you both so much for taking a look into this issue for me! I was, however, able to find a workaround that utilizes 7-Zip. All I had to do was reference the 7zip .exe from my project, call the Command Prompt, and pass in a single argument with the BZ2 file and where exactly it should be decompressed to. And it worked! However, I am looking forward to seeing the solution you come up with @piksel . Thank you once again!