diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_Storage/Given_StorageFile.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_Storage/Given_StorageFile.cs index 21bcd363b042..b63b3f3bb2c4 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_Storage/Given_StorageFile.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_Storage/Given_StorageFile.cs @@ -339,6 +339,17 @@ public async Task When_Open_By_Encoded_URI_With_Space() } } + [TestMethod] + public async Task When_Open_Multiple_Reads_Single_Write() + { + var uri = new Uri($"ms-appx:///Assets/Asset With Spaces.svg"); + var file = await StorageFile.GetFileFromApplicationUriAsync(uri); + _ = await file.OpenStreamForReadAsync(); + _ = await file.OpenStreamForReadAsync(); + _ = await file.OpenStreamForWriteAsync(); + _ = await file.OpenStreamForReadAsync(); + } + [TestMethod] #if __MACOS__ && !NET6_0_OR_GREATER [Ignore] // Not supported for Xamarin.mac target diff --git a/src/Uno.UWP/System.IO/WindowsRuntimeStorageExtensions.cs b/src/Uno.UWP/System.IO/WindowsRuntimeStorageExtensions.cs index 8fdc79844076..3cd5a886c7ec 100644 --- a/src/Uno.UWP/System.IO/WindowsRuntimeStorageExtensions.cs +++ b/src/Uno.UWP/System.IO/WindowsRuntimeStorageExtensions.cs @@ -13,7 +13,7 @@ public static async Task OpenStreamForReadAsync(this IStorageFile window { if (windowsRuntimeFile is StorageFile file) { - return await file.OpenStream(CancellationToken.None, FileAccessMode.Read, StorageOpenOptions.None); + return await file.OpenStream(CancellationToken.None, FileAccessMode.Read, StorageOpenOptions.AllowReadersAndWriters); } else { @@ -32,7 +32,7 @@ public static async Task OpenStreamForWriteAsync(this IStorageFile windo { if (windowsRuntimeFile is StorageFile file) { - return await file.OpenStream(CancellationToken.None, FileAccessMode.ReadWrite, StorageOpenOptions.None); + return await file.OpenStream(CancellationToken.None, FileAccessMode.ReadWrite, StorageOpenOptions.AllowOnlyReaders); } else {