From ba28d2dc9b578f1e79eb5f5d816548b5d1398c8b Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 21 Jul 2014 12:39:57 +0100 Subject: [PATCH] Added function to get drives --- Saviour Backup System/USBTools.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Saviour Backup System/USBTools.cs b/Saviour Backup System/USBTools.cs index 4c83158..9b9d92c 100644 --- a/Saviour Backup System/USBTools.cs +++ b/Saviour Backup System/USBTools.cs @@ -9,9 +9,20 @@ namespace Saviour_Backup_System { public class USBTools { - public void updateDriveList() + public DriveInfo[] getConnectedDrives() { - //Get code for scanning drive (from other project) here + List drivesList = new List(); + DriveInfo[] drives = DriveInfo.GetDrives(); + foreach (DriveInfo drive in drives) { + 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; + } + drivesList.Add(drive); + } + return drivesList.ToArray(); } } }