I think I found the problem.
When I changed the code to do this:
using (var stream = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.Write)) { using (var package = Package.Open(stream)) {
I got a pretty decent error message:
The package cannot be opened because the FileMode or FileAccess value is not valid for the stream.
I think there is a βrealβ error message, and that somewhere someone just mixed it up with this pointless when doing localization.
Then I changed the code for this:
// no FileAccess parameter using (var package = Package.Open(file, FileMode.OpenOrCreate)) { // do something with package }
And it won't work anymore and seems to be working correctly.
Etienne de martel
source share