diff options
Diffstat (limited to 'Software/Visual_Studio/FSE/Modules/Tango.FSE.Firmware/ViewModels/FileSystemViewVM.cs')
| -rw-r--r-- | Software/Visual_Studio/FSE/Modules/Tango.FSE.Firmware/ViewModels/FileSystemViewVM.cs | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Firmware/ViewModels/FileSystemViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Firmware/ViewModels/FileSystemViewVM.cs index 4c88d65be..e2be72127 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.Firmware/ViewModels/FileSystemViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.Firmware/ViewModels/FileSystemViewVM.cs @@ -433,40 +433,47 @@ namespace Tango.FSE.Firmware.ViewModels private async void UploadFiles(List<String> files) { - String currentPathBefore = CurrentPath; - - foreach (var file in files) - { - if (!File.Exists(file)) - { - await NotificationProvider.ShowError($"File '{file}' cannot be uploaded."); - return; - } - } - - foreach (var file in files) + try { - String itemName = Path.GetFileName(file); + String currentPathBefore = CurrentPath; - if ((CurrentItem as IFileSystemContainer).Items.ToList().Exists(x => x.Name.ToLower() == itemName.ToLower())) + foreach (var file in files) { - if (!await NotificationProvider.ShowWarningQuestion($"'{itemName}' already exists on '{CurrentItem.Name}'. Do you want to overwrite?")) + if (!File.Exists(file)) { - continue; + await NotificationProvider.ShowError($"File '{file}' cannot be uploaded."); + return; } } - var handler = await FirmwareStorageProvider.Upload(file, Path.Combine(CurrentItem.Path, Path.GetFileName(file))); - - handler.StatusChanged += (x, status) => + foreach (var file in files) { - if (status == FileSystemHandlerStatus.Completed && currentPathBefore == CurrentPath) + String itemName = Path.GetFileName(file); + + if ((CurrentItem as IFileSystemContainer).Items.ToList().Exists(x => x.Name.ToLower() == itemName.ToLower())) { - NavigateToCurrentPath(); + if (!await NotificationProvider.ShowWarningQuestion($"'{itemName}' already exists on '{CurrentItem.Name}'. Do you want to overwrite?")) + { + continue; + } } - }; - FileSystemHandlers.Insert(0, handler); + var handler = await FirmwareStorageProvider.Upload(file, Path.Combine(CurrentItem.Path, Path.GetFileName(file))); + + handler.StatusChanged += (x, status) => + { + if (status == FileSystemHandlerStatus.Completed && currentPathBefore == CurrentPath) + { + NavigateToCurrentPath(); + } + }; + + FileSystemHandlers.Insert(0, handler); + } + } + catch (Exception ex) + { + await NotificationProvider.ShowError($"Error uploading to file system.\n{ex.FlattenMessage()}"); } } |
