|
1 | 1 | using Files.Filesystem; |
| 2 | +using Files.Helpers; |
2 | 3 | using System; |
3 | 4 | using System.Collections.Generic; |
4 | 5 | using Windows.Storage; |
@@ -74,22 +75,29 @@ public static async void CreateFile(AddItemType itemType) |
74 | 75 |
|
75 | 76 | // Create file based on dialog result |
76 | 77 | string userInput = renameDialog.storedRenameInput; |
77 | | - switch (itemType) |
| 78 | + try |
78 | 79 | { |
79 | | - case AddItemType.Folder: |
80 | | - userInput = !string.IsNullOrWhiteSpace(userInput) ? userInput : ResourceController.GetTranslation("NewFolder"); |
81 | | - await folderToCreateItem.CreateFolderAsync(userInput, CreationCollisionOption.GenerateUniqueName); |
82 | | - break; |
| 80 | + switch (itemType) |
| 81 | + { |
| 82 | + case AddItemType.Folder: |
| 83 | + userInput = !string.IsNullOrWhiteSpace(userInput) ? userInput : ResourceController.GetTranslation("NewFolder"); |
| 84 | + await folderToCreateItem.CreateFolderAsync(userInput, CreationCollisionOption.GenerateUniqueName); |
| 85 | + break; |
83 | 86 |
|
84 | | - case AddItemType.TextDocument: |
85 | | - userInput = !string.IsNullOrWhiteSpace(userInput) ? userInput : ResourceController.GetTranslation("NewTextDocument"); |
86 | | - await folderToCreateItem.CreateFileAsync(userInput + ".txt", CreationCollisionOption.GenerateUniqueName); |
87 | | - break; |
| 87 | + case AddItemType.TextDocument: |
| 88 | + userInput = !string.IsNullOrWhiteSpace(userInput) ? userInput : ResourceController.GetTranslation("NewTextDocument"); |
| 89 | + await folderToCreateItem.CreateFileAsync(userInput + ".txt", CreationCollisionOption.GenerateUniqueName); |
| 90 | + break; |
88 | 91 |
|
89 | | - case AddItemType.BitmapImage: |
90 | | - userInput = !string.IsNullOrWhiteSpace(userInput) ? userInput : ResourceController.GetTranslation("NewBitmapImage"); |
91 | | - await folderToCreateItem.CreateFileAsync(userInput + ".bmp", CreationCollisionOption.GenerateUniqueName); |
92 | | - break; |
| 92 | + case AddItemType.BitmapImage: |
| 93 | + userInput = !string.IsNullOrWhiteSpace(userInput) ? userInput : ResourceController.GetTranslation("NewBitmapImage"); |
| 94 | + await folderToCreateItem.CreateFileAsync(userInput + ".bmp", CreationCollisionOption.GenerateUniqueName); |
| 95 | + break; |
| 96 | + } |
| 97 | + } |
| 98 | + catch (UnauthorizedAccessException) |
| 99 | + { |
| 100 | + await DialogDisplayHelper.ShowDialog(ResourceController.GetTranslation("AccessDeniedCreateDialog/Title"), ResourceController.GetTranslation("AccessDeniedCreateDialog/Text")); |
93 | 101 | } |
94 | 102 | } |
95 | 103 | } |
|
0 commit comments