public void Test()
{
var cf = new CompoundFile();
const string DATA = "data";
var st = cf.RootStorage.AddStream(DATA);
const int size = 10;
var data = Enumerable.Range(0, size).Select(v => (byte)v).ToArray();
st.SetData(data);
var ms = new MemoryStream();
cf.Save(ms);
cf.Close();
ms.Position = 0;
cf = new CompoundFile(ms, CFSUpdateMode.Update, CFSConfiguration.Default);
st = cf.RootStorage.GetStream(DATA);
st.Resize(5); // <- can be any number smaller than the current size
st.Write(new byte[] { 0 }, 0); // <- exception here!
cf.Commit();
cf.Close();
}
Looks like truncating the stream does not work.