Use null coalescing when possible

This commit is contained in:
crobibero
2020-11-13 11:24:46 -07:00
parent 5f52a58e78
commit 95ebb9a55a
13 changed files with 22 additions and 110 deletions

View File

@@ -128,12 +128,7 @@ namespace MediaBrowser.LocalMetadata.Savers
private void SaveToFile(Stream stream, string path)
{
var directory = Path.GetDirectoryName(path);
if (directory == null)
{
throw new ResourceNotFoundException(nameof(directory));
}
var directory = Path.GetDirectoryName(path) ?? throw new ResourceNotFoundException(nameof(path));
Directory.CreateDirectory(directory);
// On Windows, savint the file will fail if the file is hidden or readonly
FileSystem.SetAttributes(path, false, false);