From 49a8617305e063ad60be4ee5c2deaf10e0e5e248 Mon Sep 17 00:00:00 2001
From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch>
Date: Thu, 8 Feb 2018 00:02:37 +0100
Subject: [PATCH] Validate drive location of a new transfer directory.

This is the last missing strict requirement for the first version of a
tray app, so this commit closes #2.
---
 ATxTray/AutoTxTray.cs | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/ATxTray/AutoTxTray.cs b/ATxTray/AutoTxTray.cs
index 91b44b7..d7f6ff3 100644
--- a/ATxTray/AutoTxTray.cs
+++ b/ATxTray/AutoTxTray.cs
@@ -59,6 +59,7 @@ namespace ATxTray
 
         private static TaskDialog _confirmDialog;
         private static DirectoryInfo _selectedDir;
+
         public AutoTxTray() {
             
             #region logging configuration
@@ -245,6 +246,14 @@ namespace ATxTray
                 return;
 
             _selectedDir = new DirectoryInfo(dirDialog.FileName);
+            var drive = dirDialog.FileName.Substring(0, 3);
+            if (drive != _config.SourceDrive) {
+                MessageBox.Show($@"The selected directory '{_selectedDir}' is required to be on " +
+                    $@"drive {_config.SourceDrive}, please choose another directory!",
+                    @"Selected directory on wrong drive", MessageBoxButtons.OK, MessageBoxIcon.Error);
+                return;
+            }
+
             var folderName = _selectedDir.Name;
             var locationPath = _selectedDir.Parent?.FullName;
             var size = Conv.BytesToString(FsUtils.GetDirectorySize(_selectedDir.FullName));
-- 
GitLab