Closed ArminFirecracker closed 6 years ago
When opening a file in update mode and appending big arrays, I get an exception:
System.ArgumentOutOfRangeException: 'Non-negative number required.
This could be fixed by casting in the corresponding line to long.
CompoundFile.cs, line 650 sourceStream.SetLength((long)(sectors.Count + 1) * sSize);
sourceStream.SetLength((long)(sectors.Count + 1) * sSize);
What do you say?
String filename = "MyFile.dat"; String storageName = "MyStorage"; String streamName = "MyStream"; int bufferSize = 500000000; int iterationCount = 3; int streamCount = 3; CompoundFile compoundFileInit = new CompoundFile(CFSVersion.Ver_4, CFSConfiguration.Default); compoundFileInit.Save(filename); compoundFileInit.Close(); CompoundFile compoundFile = new CompoundFile(filename, CFSUpdateMode.Update, CFSConfiguration.Default); CFStorage st = compoundFile.RootStorage.AddStorage(storageName); for (int streamId = 0; streamId < streamCount; ++streamId) { CFStream sm = st.AddStream(streamName + streamId); for (int iteration = 0; iteration < iterationCount; ++iteration) { sm.Append(new byte[bufferSize]); compoundFile.Commit(); } } compoundFile.Close();
Thank you very much for your advice. Committed to main with unit test based on your code. Best Regards, Federico
Nuget package released, 2.1.4.23498
When opening a file in update mode and appending big arrays, I get an exception:
This could be fixed by casting in the corresponding line to long.
CompoundFile.cs, line 650
sourceStream.SetLength((long)(sectors.Count + 1) * sSize);
What do you say?