Add safety around volume labels

This commit is contained in:
Matt Nadareski
2021-12-29 10:00:28 -08:00
parent 982a217d32
commit f6b78c07ca
2 changed files with 16 additions and 1 deletions

View File

@@ -47,6 +47,7 @@
- Validate track count when matching Redump
- Allow for better matching of multi track discs
- Temporarily disable pulling comments from Redump pages
- Add safety around volume labels
### 2.1 (2021-07-22)
- Enum, no more

View File

@@ -48,7 +48,21 @@ namespace MPF.Core.Data
/// <summary>
/// Media label as read by Windows
/// </summary>
public string VolumeLabel => driveInfo?.VolumeLabel;
/// <remarks>The try/catch is needed because Windows will throw an exception if the drive is not marked as active</remarks>
public string VolumeLabel
{
get
{
try
{
return driveInfo?.VolumeLabel;
}
catch
{
return null;
}
}
}
/// <summary>
/// Media label as read by Windows, formatted to avoid odd outputs