#28 : Ensured nodrives mechanism in file system dialog doesn't crash if registry value doesn't exist.
This commit is contained in:
parent
9b8379bdae
commit
4bccf4610b
2 changed files with 4 additions and 4 deletions
|
@ -292,9 +292,9 @@ namespace SafeExamBrowser.UserInterface.Desktop.Windows
|
||||||
private DriveInfo[] GetDrives()
|
private DriveInfo[] GetDrives()
|
||||||
{
|
{
|
||||||
var drives = DriveInfo.GetDrives();
|
var drives = DriveInfo.GetDrives();
|
||||||
var noDrives = (int) Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoDrives", 0);
|
var noDrives = Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoDrives", 0) as int?;
|
||||||
|
|
||||||
if (noDrives > 0)
|
if (noDrives.HasValue && noDrives > 0)
|
||||||
{
|
{
|
||||||
return drives.Where(drive => (noDrives & (int) Math.Pow(2, drive.RootDirectory.ToString()[0] - 65)) == 0).ToArray();
|
return drives.Where(drive => (noDrives & (int) Math.Pow(2, drive.RootDirectory.ToString()[0] - 65)) == 0).ToArray();
|
||||||
}
|
}
|
||||||
|
|
|
@ -292,9 +292,9 @@ namespace SafeExamBrowser.UserInterface.Mobile.Windows
|
||||||
private DriveInfo[] GetDrives()
|
private DriveInfo[] GetDrives()
|
||||||
{
|
{
|
||||||
var drives = DriveInfo.GetDrives();
|
var drives = DriveInfo.GetDrives();
|
||||||
var noDrives = (int) Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoDrives", 0);
|
var noDrives = Registry.GetValue("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoDrives", 0) as int?;
|
||||||
|
|
||||||
if (noDrives > 0)
|
if (noDrives.HasValue && noDrives > 0)
|
||||||
{
|
{
|
||||||
return drives.Where(drive => (noDrives & (int) Math.Pow(2, drive.RootDirectory.ToString()[0] - 65)) == 0).ToArray();
|
return drives.Where(drive => (noDrives & (int) Math.Pow(2, drive.RootDirectory.ToString()[0] - 65)) == 0).ToArray();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue