Skip to content

Commit 9b5cffc

Browse files
authored
Fixed a crash that would occur when creating an element in a folder that requires elevation (#2057)
1 parent bfa7229 commit 9b5cffc

18 files changed

+155
-13
lines changed

Files/Dialogs/AddItemDialog.xaml.cs

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Files.Filesystem;
2+
using Files.Helpers;
23
using System;
34
using System.Collections.Generic;
45
using Windows.Storage;
@@ -74,22 +75,29 @@ public static async void CreateFile(AddItemType itemType)
7475

7576
// Create file based on dialog result
7677
string userInput = renameDialog.storedRenameInput;
77-
switch (itemType)
78+
try
7879
{
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;
8386

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;
8891

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"));
93101
}
94102
}
95103
}

Files/MultilingualResources/Files.de-DE.xlf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,14 @@
13611361
<source>Support us on PayPal</source>
13621362
<target state="new">Support us on PayPal</target>
13631363
</trans-unit>
1364+
<trans-unit id="AccessDeniedCreateDialog.Text" translate="yes" xml:space="preserve">
1365+
<source>We weren't able to create this item</source>
1366+
<target state="new">We weren't able to create this item</target>
1367+
</trans-unit>
1368+
<trans-unit id="AccessDeniedCreateDialog.Title" translate="yes" xml:space="preserve">
1369+
<source>Access Denied</source>
1370+
<target state="new">Access Denied</target>
1371+
</trans-unit>
13641372
</group>
13651373
</body>
13661374
</file>

Files/MultilingualResources/Files.es-ES.xlf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,14 @@
13551355
<source>Support us on PayPal</source>
13561356
<target state="new">Support us on PayPal</target>
13571357
</trans-unit>
1358+
<trans-unit id="AccessDeniedCreateDialog.Text" translate="yes" xml:space="preserve">
1359+
<source>We weren't able to create this item</source>
1360+
<target state="new">We weren't able to create this item</target>
1361+
</trans-unit>
1362+
<trans-unit id="AccessDeniedCreateDialog.Title" translate="yes" xml:space="preserve">
1363+
<source>Access Denied</source>
1364+
<target state="new">Access Denied</target>
1365+
</trans-unit>
13581366
</group>
13591367
</body>
13601368
</file>

Files/MultilingualResources/Files.fr-FR.xlf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,14 @@
13551355
<source>Support us on PayPal</source>
13561356
<target state="new">Support us on PayPal</target>
13571357
</trans-unit>
1358+
<trans-unit id="AccessDeniedCreateDialog.Text" translate="yes" xml:space="preserve">
1359+
<source>We weren't able to create this item</source>
1360+
<target state="new">We weren't able to create this item</target>
1361+
</trans-unit>
1362+
<trans-unit id="AccessDeniedCreateDialog.Title" translate="yes" xml:space="preserve">
1363+
<source>Access Denied</source>
1364+
<target state="new">Access Denied</target>
1365+
</trans-unit>
13581366
</group>
13591367
</body>
13601368
</file>

Files/MultilingualResources/Files.he-IL.xlf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,14 @@
13571357
<source>Support us on PayPal</source>
13581358
<target state="new">Support us on PayPal</target>
13591359
</trans-unit>
1360+
<trans-unit id="AccessDeniedCreateDialog.Text" translate="yes" xml:space="preserve">
1361+
<source>We weren't able to create this item</source>
1362+
<target state="new">We weren't able to create this item</target>
1363+
</trans-unit>
1364+
<trans-unit id="AccessDeniedCreateDialog.Title" translate="yes" xml:space="preserve">
1365+
<source>Access Denied</source>
1366+
<target state="new">Access Denied</target>
1367+
</trans-unit>
13601368
</group>
13611369
</body>
13621370
</file>

Files/MultilingualResources/Files.hi-IN.xlf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,14 @@
13681368
<source>Support us on PayPal</source>
13691369
<target state="new">Support us on PayPal</target>
13701370
</trans-unit>
1371+
<trans-unit id="AccessDeniedCreateDialog.Text" translate="yes" xml:space="preserve">
1372+
<source>We weren't able to create this item</source>
1373+
<target state="new">We weren't able to create this item</target>
1374+
</trans-unit>
1375+
<trans-unit id="AccessDeniedCreateDialog.Title" translate="yes" xml:space="preserve">
1376+
<source>Access Denied</source>
1377+
<target state="new">Access Denied</target>
1378+
</trans-unit>
13711379
</group>
13721380
</body>
13731381
</file>

Files/MultilingualResources/Files.it-IT.xlf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,14 @@
13691369
<source>Support us on PayPal</source>
13701370
<target state="new">Support us on PayPal</target>
13711371
</trans-unit>
1372+
<trans-unit id="AccessDeniedCreateDialog.Text" translate="yes" xml:space="preserve">
1373+
<source>We weren't able to create this item</source>
1374+
<target state="new">We weren't able to create this item</target>
1375+
</trans-unit>
1376+
<trans-unit id="AccessDeniedCreateDialog.Title" translate="yes" xml:space="preserve">
1377+
<source>Access Denied</source>
1378+
<target state="new">Access Denied</target>
1379+
</trans-unit>
13721380
</group>
13731381
</body>
13741382
</file>

Files/MultilingualResources/Files.ja-JP.xlf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,14 @@
13691369
<source>Support us on PayPal</source>
13701370
<target state="new">Support us on PayPal</target>
13711371
</trans-unit>
1372+
<trans-unit id="AccessDeniedCreateDialog.Text" translate="yes" xml:space="preserve">
1373+
<source>We weren't able to create this item</source>
1374+
<target state="new">We weren't able to create this item</target>
1375+
</trans-unit>
1376+
<trans-unit id="AccessDeniedCreateDialog.Title" translate="yes" xml:space="preserve">
1377+
<source>Access Denied</source>
1378+
<target state="new">Access Denied</target>
1379+
</trans-unit>
13721380
</group>
13731381
</body>
13741382
</file>

Files/MultilingualResources/Files.nl-NL.xlf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,14 @@
13691369
<source>Support us on PayPal</source>
13701370
<target state="new">Support us on PayPal</target>
13711371
</trans-unit>
1372+
<trans-unit id="AccessDeniedCreateDialog.Text" translate="yes" xml:space="preserve">
1373+
<source>We weren't able to create this item</source>
1374+
<target state="new">We weren't able to create this item</target>
1375+
</trans-unit>
1376+
<trans-unit id="AccessDeniedCreateDialog.Title" translate="yes" xml:space="preserve">
1377+
<source>Access Denied</source>
1378+
<target state="new">Access Denied</target>
1379+
</trans-unit>
13721380
</group>
13731381
</body>
13741382
</file>

Files/MultilingualResources/Files.or-IN.xlf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,14 @@
13681368
<source>Support us on PayPal</source>
13691369
<target state="new">Support us on PayPal</target>
13701370
</trans-unit>
1371+
<trans-unit id="AccessDeniedCreateDialog.Text" translate="yes" xml:space="preserve">
1372+
<source>We weren't able to create this item</source>
1373+
<target state="new">We weren't able to create this item</target>
1374+
</trans-unit>
1375+
<trans-unit id="AccessDeniedCreateDialog.Title" translate="yes" xml:space="preserve">
1376+
<source>Access Denied</source>
1377+
<target state="new">Access Denied</target>
1378+
</trans-unit>
13711379
</group>
13721380
</body>
13731381
</file>

0 commit comments

Comments
 (0)