I have an object that has a byte array property ‘ZipFile’ to store a file stream:
Property in Result class:
public class Result
{
public byte[] ZipFile;
}
In my application, I generate a PDF file, and read the file into the ‘ZipFile’ property using my ReadFile method like this :
objResult.ZipFile = ReadFile(FilePath);
Signature of ReadFile method:
private byte[] ReadFile(string strFileName)
The Problem:
My ReadFile method will now be called in a loop, because I am generating multiple PDF files. Each time the ReadFile method will read a new file from the specifed parameter to the ‘objResult.ZipFile’ property, consequently replacing the old value in ‘ZipFile’ property. Now, I want my ‘ZipFile’ property to store multiple PDF files stream. So what should I do for that? Should I just change this property to a two dimensional byte[][] array, or is there any better way to do this? Remember, that this property will be used for saving(writing) these files by calling method. Open to all Suggestions. Thanks.
Sounds like you should either have a
List<Result>, or result should have a collection such asList<byte[]>as aZipFilesproperty. Note that currently you don’t have a property at all – you have a public field, which is generally a bad idea.(You probably wouldn’t expose it as a
List<byte[]>– that would be the underlying implementation. I’d probably make it anIEnumerable<byte[]>and expose anAddZipFilemethod.)