Partial fix for https://bugzilla.xamarin.com/show_bug.cgi?id=39282.
Partial fix for https://github.com/OfficeDev/Open-XML-SDK/issues/64.
{
stream.Position = origin.Value;
}
+ length = bytesToRead;
BytesLeftToRead = bytesToRead;
}
}
}
+ private long length;
+
private long BytesLeftToRead { get; set; }
public Stream Stream { get; private set; }
public override long Length
{
- get { throw new System.NotImplementedException(); }
+ get { return length; }
}
public override long Position
{
- get { throw new System.NotImplementedException(); }
+ get { return Length - BytesLeftToRead; }
set { throw new System.NotImplementedException(); }
}
}
}
+ [Test]
+ public void ZipGetArchiveEntryStreamLengthPositionReadMode()
+ {
+ using (var archive = new ZipArchive(File.Open("test.nupkg", FileMode.Open),
+ ZipArchiveMode.Read))
+ {
+ var entry = archive.GetEntry("_rels/.rels");
+ using (var stream = entry.Open())
+ {
+ Assert.AreEqual(0, stream.Position);
+ Assert.AreEqual(425, stream.Length);
+ }
+ }
+ }
+
[Test]
public void ZipEnumerateEntriesReadMode()
{