Stumbled across an odd and unexpected issue whereby this programmatically generated zip file encounters the “Value cannot be null. Parameter name: source” exception.
It appears that the text file content somehow creates a zip file whereby the GroupDocs.Parser isn’t able to handle when doing Stream parsing.
Parsing using filename with extension or specifying FileFormat.Archive works fine.
Guess the exception occurs when the parser is trying to figure out the format of the stream.
Odd this is that by simply changing the text file content to something else will not hit the exception.
string file1 = Path.Combine(zipFolder, "a.txt");
File.WriteAllText(file1, "The quick brown fox jumps over the lazy dog");
string zipFilePath = Path.Combine(tmpFolder, "test.zip");
System.IO.Compression.ZipFile.CreateFromDirectory(zipFolder, zipFilePath);
try
{
using (FileStream s = File.OpenRead(zipFilePath))
{
using (GroupDocs.Parser.Parser parser = new GroupDocs.Parser.Parser(s)) //, new GroupDocs.Parser.Options.LoadOptions(GroupDocs.Parser.Options.FileFormat.Archive)))
{
var cItems = parser.GetContainer();
Console.WriteLine($"Count = {cItems.Count()}");
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}