Skip to content

Commit 7ec795c

Browse files
authored
Be explicit about FileShare mode when using FileStream. (#240)
We know that by default `FileShare` will be `Read` when using a `FileStream`. However lets be totally clear on what we want from this point on, so if there is a problem we know its not us.
1 parent 3debf8e commit 7ec795c

File tree

1 file changed

+2
-2
lines changed
  • src/Microsoft.Android.Build.BaseTasks

1 file changed

+2
-2
lines changed

src/Microsoft.Android.Build.BaseTasks/Files.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ public static string HashFile (string filename)
435435

436436
public static string HashFile (string filename, HashAlgorithm hashAlg)
437437
{
438-
using (Stream file = new FileStream (filename, FileMode.Open, FileAccess.Read)) {
438+
using (Stream file = new FileStream (filename, FileMode.Open, FileAccess.Read, FileShare.Read)) {
439439
byte[] hash = hashAlg.ComputeHash (file);
440440
return ToHexString (hash);
441441
}
@@ -479,7 +479,7 @@ public static void DeleteFile (string filename, object log)
479479
public static bool IsPortablePdb (string filename)
480480
{
481481
try {
482-
using (var fs = new FileStream (filename, FileMode.Open, FileAccess.Read)) {
482+
using (var fs = new FileStream (filename, FileMode.Open, FileAccess.Read, FileShare.Read)) {
483483
using (var br = new BinaryReader (fs)) {
484484
return br.ReadUInt32 () == ppdb_signature;
485485
}

0 commit comments

Comments
 (0)