Use FileShare.None when creating files

This commit is contained in:
David
2021-03-07 14:43:28 +01:00
parent 22402650cb
commit 60ffa6f514
16 changed files with 36 additions and 18 deletions

View File

@@ -133,7 +133,8 @@ namespace MediaBrowser.LocalMetadata.Savers
// On Windows, savint the file will fail if the file is hidden or readonly
FileSystem.SetAttributes(path, false, false);
using (var filestream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.Read))
// use FileShare.None as this bypasses dotnet bug dotnet/runtime#42790 .
using (var filestream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None))
{
stream.CopyTo(filestream);
}