diff --git a/osu.Game/Database/ArchiveModelManager.cs b/osu.Game/Database/ArchiveModelManager.cs index a0ca23eaec..f3ed2d735b 100644 --- a/osu.Game/Database/ArchiveModelManager.cs +++ b/osu.Game/Database/ArchiveModelManager.cs @@ -462,10 +462,10 @@ namespace osu.Game.Database if (retrievedItem == null) throw new ArgumentException(@"Specified model could not be found", nameof(item)); - var filename = $"{getValidFilename(item.ToString())}{HandledExtensions.First()}"; + string filename = $"{getValidFilename(item.ToString())}{HandledExtensions.First()}"; - using (var outputStream = exportStorage.GetStream(filename, FileAccess.Write, FileMode.Create)) - ExportModelTo(retrievedItem, outputStream); + using (var stream = exportStorage.GetStream(filename, FileAccess.Write, FileMode.Create)) + ExportModelTo(retrievedItem, stream); exportStorage.PresentFileExternally(filename); } diff --git a/osu.Game/Graphics/ScreenshotManager.cs b/osu.Game/Graphics/ScreenshotManager.cs index c21986f6c4..e652f07239 100644 --- a/osu.Game/Graphics/ScreenshotManager.cs +++ b/osu.Game/Graphics/ScreenshotManager.cs @@ -109,40 +109,42 @@ namespace osu.Game.Graphics if (Interlocked.Decrement(ref screenShotTasks) == 0 && cursorVisibility.Value == false) cursorVisibility.Value = true; - var fileName = getFileName(); - if (fileName == null) return; + string filename = getFilename(); - var stream = storage.GetStream(fileName, FileAccess.Write); + if (filename == null) return; - switch (screenshotFormat.Value) + using (var stream = storage.GetStream(filename, FileAccess.Write)) { - case ScreenshotFormat.Png: - await image.SaveAsPngAsync(stream).ConfigureAwait(false); - break; + switch (screenshotFormat.Value) + { + case ScreenshotFormat.Png: + await image.SaveAsPngAsync(stream).ConfigureAwait(false); + break; - case ScreenshotFormat.Jpg: - const int jpeg_quality = 92; + case ScreenshotFormat.Jpg: + const int jpeg_quality = 92; - await image.SaveAsJpegAsync(stream, new JpegEncoder { Quality = jpeg_quality }).ConfigureAwait(false); - break; + await image.SaveAsJpegAsync(stream, new JpegEncoder { Quality = jpeg_quality }).ConfigureAwait(false); + break; - default: - throw new InvalidOperationException($"Unknown enum member {nameof(ScreenshotFormat)} {screenshotFormat.Value}."); + default: + throw new InvalidOperationException($"Unknown enum member {nameof(ScreenshotFormat)} {screenshotFormat.Value}."); + } } notificationOverlay.Post(new SimpleNotification { - Text = $"{fileName} saved!", + Text = $"{filename} saved!", Activated = () => { - storage.PresentFileExternally(fileName); + storage.PresentFileExternally(filename); return true; } }); } }); - private string getFileName() + private string getFilename() { var dt = DateTime.Now; var fileExt = screenshotFormat.ToString().ToLowerInvariant();