Skip to content

Commit 12f32a3

Browse files
authored
Use OPEN_EXISTING when opening a file for read (#9273)
1 parent fec43a0 commit 12f32a3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Files.Uwp/Helpers/NativeFileOperationsHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public static SafeFileHandle CreateFileForWrite(string filePath, bool overwrite
8585
public static SafeFileHandle OpenFileForRead(string filePath, bool readWrite = false, uint flags = 0)
8686
{
8787
return new SafeFileHandle(CreateFileFromApp(filePath,
88-
GENERIC_READ | (readWrite ? GENERIC_WRITE : 0), FILE_SHARE_READ | FILE_SHARE_WRITE, IntPtr.Zero, OPEN_ALWAYS, (uint)File_Attributes.BackupSemantics | flags, IntPtr.Zero), true);
88+
GENERIC_READ | (readWrite ? GENERIC_WRITE : 0), FILE_SHARE_READ | (readWrite ? 0 :FILE_SHARE_WRITE), IntPtr.Zero, OPEN_EXISTING, (uint)File_Attributes.BackupSemantics | flags, IntPtr.Zero), true);
8989
}
9090

9191
private const int MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16 * 1024;

0 commit comments

Comments
 (0)