From 4f732557b91e77355cae14601b57e9cdd33337a3 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 14 Aug 2020 12:59:23 -0700 Subject: [PATCH] Drive label should not contain bad chars --- DICUI.Library/Utilities/Drive.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/DICUI.Library/Utilities/Drive.cs b/DICUI.Library/Utilities/Drive.cs index 3bd90358..594a99cd 100644 --- a/DICUI.Library/Utilities/Drive.cs +++ b/DICUI.Library/Utilities/Drive.cs @@ -30,17 +30,19 @@ namespace DICUI.Utilities { get { + string volumeLabel = Template.DiscNotDetected; if (DriveInfo.IsReady) { if (string.IsNullOrWhiteSpace(DriveInfo.VolumeLabel)) - return "track"; + volumeLabel = "track"; else - return DriveInfo.VolumeLabel; - } - else - { - return Template.DiscNotDetected; + volumeLabel = DriveInfo.VolumeLabel; } + + foreach (char c in Path.GetInvalidFileNameChars()) + volumeLabel = volumeLabel.Replace(c, '_'); + + return volumeLabel; } }