diff --git a/OpenMcdf/RootStorage.cs b/OpenMcdf/RootStorage.cs index 8ded764..e567036 100644 --- a/OpenMcdf/RootStorage.cs +++ b/OpenMcdf/RootStorage.cs @@ -39,7 +39,7 @@ private static void ThrowIfInvalid(FileAccess access) private static void ThrowIfLeaveOpen(StorageModeFlags flags) { if (flags.HasFlag(StorageModeFlags.LeaveOpen)) - throw new ArgumentException($"{StorageModeFlags.LeaveOpen} is not valid for files"); + throw new ArgumentException($"{StorageModeFlags.LeaveOpen} is only valid for injected streams."); } private static IOContextFlags ToIOContextFlags(StorageModeFlags flags) @@ -78,7 +78,12 @@ public static RootStorage Create(Stream stream, Version version = Version.V3, St return new RootStorage(rootContextSite, flags); } - public static RootStorage CreateInMemory(Version version = Version.V3, StorageModeFlags flags = StorageModeFlags.None) => Create(new MemoryStream(), version, flags); + public static RootStorage CreateInMemory(Version version = Version.V3, StorageModeFlags flags = StorageModeFlags.None) + { + ThrowIfLeaveOpen(flags); + + return Create(new MemoryStream(), version, flags); + } public static RootStorage Open(string fileName, FileMode mode, StorageModeFlags flags = StorageModeFlags.None) {