From 011a1c392117d390497f254eb08b7e6301bd186b Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 22 Jul 2014 21:12:00 +0100 Subject: [PATCH] Changed function definition, optimized code, and added function for ejecting drive --- Saviour Backup System/USBTools.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Saviour Backup System/USBTools.cs b/Saviour Backup System/USBTools.cs index 9b9d92c..7daadbe 100644 --- a/Saviour Backup System/USBTools.cs +++ b/Saviour Backup System/USBTools.cs @@ -9,7 +9,7 @@ namespace Saviour_Backup_System { public class USBTools { - public DriveInfo[] getConnectedDrives() + public static DriveInfo[] getConnectedDrives() { List drivesList = new List(); DriveInfo[] drives = DriveInfo.GetDrives(); @@ -17,12 +17,15 @@ namespace Saviour_Backup_System try { string driveName = drive.VolumeLabel; string driveLetter = drive.Name; - } catch { // If there is a problem getting the drive data, then the program would crash! - continue; - } + } catch { continue; } drivesList.Add(drive); } return drivesList.ToArray(); } + public void safelyEjectDrive(string driveChar) + { + driveChar = driveChar.Remove(driveChar.Length - 1); + RemoveDriveTools.RemoveDrive(driveChar); + } } }