diff --git a/OpenMcdf.Tests/RootStorageTests.cs b/OpenMcdf.Tests/RootStorageTests.cs index a118a20..54600b4 100644 --- a/OpenMcdf.Tests/RootStorageTests.cs +++ b/OpenMcdf.Tests/RootStorageTests.cs @@ -12,6 +12,7 @@ public void Open(string fileName) using var rootStorage2 = RootStorage.OpenRead(fileName); Assert.ThrowsException(() => RootStorage.Open(fileName, FileMode.Open)); + Assert.ThrowsException(() => RootStorage.Open(fileName, FileMode.Open, FileAccess.ReadWrite)); Assert.ThrowsException(() => RootStorage.OpenWrite(fileName)); } diff --git a/OpenMcdf/RootStorage.cs b/OpenMcdf/RootStorage.cs index 8c7dd5d..651a088 100644 --- a/OpenMcdf/RootStorage.cs +++ b/OpenMcdf/RootStorage.cs @@ -70,6 +70,14 @@ public static RootStorage Open(string fileName, FileMode mode, StorageModeFlags return Open(stream, flags); } + public static RootStorage Open(string fileName, FileMode mode, FileAccess access, StorageModeFlags flags = StorageModeFlags.None) + { + ThrowIfLeaveOpen(flags); + + FileStream stream = File.Open(fileName, mode, access); + return Open(stream, flags); + } + public static RootStorage Open(Stream stream, StorageModeFlags flags = StorageModeFlags.None) { stream.ThrowIfNotSeekable();