ikantspelwurdz
Well-known member
- Joined
- Dec 8, 2009
- Messages
- 49
- Programming Experience
- 1-3
I'm not an expert on how stream's work in .NET. I have a file that is basically a 7z archive, except the first 667 bytes are in XML. 7zip.exe itself can extract this file just fine.
I am trying to read it using a freeware library called "SharpCompress." It chokes when reading this file. I thought that I could trick it by opening a FileStream to the file, and setting the position ahead to 667. Unfortunately, this did not work. In looking at the SharpCompress library, I found out why - here is a function in the SevenZipArchive class (it's in C#, apologies):
What I think I want to do is have a stream that starts reading at the file's 667 position, stops reading at the end, but reports its Position as 0 and its Length as 667 bytes less than what the file actually is. The object itself should not have access to the entire file - just the array of bytes I want from the file.
Is this possible? I'm not completely familiar with how Streams work, but it seems to me like this should be possible.
I am trying to read it using a freeware library called "SharpCompress." It chokes when reading this file. I thought that I could trick it by opening a FileStream to the file, and setting the position ahead to 667. Unfortunately, this did not work. In looking at the SharpCompress library, I found out why - here is a function in the SevenZipArchive class (it's in C#, apologies):
VB.NET:
private void LoadFactory(Stream stream)
{
if (factory == null)
{
stream.Position = 0;
factory = new SevenZipHeaderFactory(stream);
}
}
What I think I want to do is have a stream that starts reading at the file's 667 position, stops reading at the end, but reports its Position as 0 and its Length as 667 bytes less than what the file actually is. The object itself should not have access to the entire file - just the array of bytes I want from the file.
Is this possible? I'm not completely familiar with how Streams work, but it seems to me like this should be possible.