diff --git a/Files/Dialogs/AddItemDialog.xaml.cs b/Files/Dialogs/AddItemDialog.xaml.cs
index 014acc24fc3c..1e0fb2cfd90a 100644
--- a/Files/Dialogs/AddItemDialog.xaml.cs
+++ b/Files/Dialogs/AddItemDialog.xaml.cs
@@ -71,7 +71,7 @@ public static async void CreateFile(AddItemType fileType)
{
folder = await folderToCreateItem.CreateFolderAsync("New Folder", CreationCollisionOption.GenerateUniqueName);
}
- TabInstance.ViewModel.AddFileOrFolder(new ListedItem(folder.FolderRelativeId) { ItemName = folder.DisplayName, ItemDateModifiedReal = DateTimeOffset.Now, LoadUnknownTypeGlyph = false, LoadFolderGlyph = true, LoadFileIcon = false, ItemType = "Folder", FileImage = null, ItemPath = folder.Path });
+ TabInstance.ViewModel.AddFileOrFolder(new ListedItem(folder.FolderRelativeId) { PrimaryItemAttribute = StorageItemTypes.Folder, ItemName = folder.DisplayName, ItemDateModifiedReal = DateTimeOffset.Now, LoadUnknownTypeGlyph = false, LoadFolderGlyph = true, LoadFileIcon = false, ItemType = "Folder", FileImage = null, ItemPath = folder.Path });
}
else if (fileType == AddItemType.TextDocument)
{
@@ -84,7 +84,7 @@ public static async void CreateFile(AddItemType fileType)
{
item = await folderToCreateItem.CreateFileAsync("New Text Document" + ".txt", CreationCollisionOption.GenerateUniqueName);
}
- TabInstance.ViewModel.AddFileOrFolder(new ListedItem(item.FolderRelativeId) { ItemName = item.DisplayName, ItemDateModifiedReal = DateTimeOffset.Now, LoadUnknownTypeGlyph = true, LoadFolderGlyph = false, LoadFileIcon = false, ItemType = item.DisplayType, FileImage = null, ItemPath = item.Path, FileExtension = item.FileType });
+ TabInstance.ViewModel.AddFileOrFolder(new ListedItem(item.FolderRelativeId) { PrimaryItemAttribute = StorageItemTypes.File, ItemName = item.DisplayName, ItemDateModifiedReal = DateTimeOffset.Now, LoadUnknownTypeGlyph = true, LoadFolderGlyph = false, LoadFileIcon = false, ItemType = item.DisplayType, FileImage = null, ItemPath = item.Path, FileExtension = item.FileType });
}
else if (fileType == AddItemType.BitmapImage)
{
@@ -97,7 +97,7 @@ public static async void CreateFile(AddItemType fileType)
{
item = await folderToCreateItem.CreateFileAsync("New Bitmap Image" + ".bmp", CreationCollisionOption.GenerateUniqueName);
}
- TabInstance.ViewModel.AddFileOrFolder(new ListedItem(item.FolderRelativeId) { ItemName = item.DisplayName, ItemDateModifiedReal = DateTimeOffset.Now, LoadUnknownTypeGlyph = true, LoadFolderGlyph = false, LoadFileIcon = false, ItemType = item.DisplayType, FileImage = null, ItemPath = item.Path, FileExtension = item.FileType });
+ TabInstance.ViewModel.AddFileOrFolder(new ListedItem(item.FolderRelativeId) { PrimaryItemAttribute = StorageItemTypes.File, ItemName = item.DisplayName, ItemDateModifiedReal = DateTimeOffset.Now, LoadUnknownTypeGlyph = true, LoadFolderGlyph = false, LoadFileIcon = false, ItemType = item.DisplayType, FileImage = null, ItemPath = item.Path, FileExtension = item.FileType });
}
}
}
diff --git a/Files/Interacts/Interaction.cs b/Files/Interacts/Interaction.cs
index 004179ec1642..c1d0d59e97b5 100644
--- a/Files/Interacts/Interaction.cs
+++ b/Files/Interacts/Interaction.cs
@@ -33,6 +33,7 @@
using Windows.UI.WindowManagement.Preview;
using Windows.UI;
using Files.View_Models;
+using GalaSoft.MvvmLight.Command;
namespace Files.Interacts
{
@@ -906,9 +907,16 @@ public async void CopyItem_ClickAsync(object sender, RoutedEventArgs e)
}
+ enum ImpossibleActionResponseTypes
+ {
+ Skip,
+ Abort
+ }
+
public async void PasteItem_ClickAsync(object sender, RoutedEventArgs e)
{
string destinationPath = CurrentInstance.ViewModel.WorkingDirectory;
+ var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForViewIndependentUse();
DataPackageView packageView = Clipboard.GetContent();
itemsToPaste = await packageView.GetStorageItemsAsync();
@@ -921,12 +929,36 @@ public async void PasteItem_ClickAsync(object sender, RoutedEventArgs e)
foreach (IStorageItem item in itemsToPaste)
{
-
if (item.IsOfType(StorageItemTypes.Folder))
{
- StorageFolder pastedFolder = await CloneDirectoryAsync(item.Path, destinationPath, item.Name, false);
- CurrentInstance.ViewModel.AddFolder(pastedFolder.Path);
- pastedItemPaths.Add(pastedFolder.Path);
+ if (destinationPath.Contains(item.Path, StringComparison.OrdinalIgnoreCase))
+ {
+ ImpossibleActionResponseTypes responseType = ImpossibleActionResponseTypes.Abort;
+ ContentDialog dialog = new ContentDialog()
+ {
+ Title = resourceLoader.GetString("ErrorDialogThisActionCannotBeDone"),
+ Content = resourceLoader.GetString("ErrorDialogTheDestinationFolder") + " (" + destinationPath.Split(Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries).Last() + ") " + resourceLoader.GetString("ErrorDialogIsASubfolder") + "(" + item.Name + ")",
+ PrimaryButtonText = resourceLoader.GetString("ErrorDialogSkip"),
+ CloseButtonText = resourceLoader.GetString("ErrorDialogCancel"),
+ PrimaryButtonCommand = new RelayCommand(() => { responseType = ImpossibleActionResponseTypes.Skip; }),
+ CloseButtonCommand = new RelayCommand(() => { responseType = ImpossibleActionResponseTypes.Abort; })
+ };
+ await dialog.ShowAsync();
+ if (responseType == ImpossibleActionResponseTypes.Skip)
+ {
+ continue;
+ }
+ else if (responseType == ImpossibleActionResponseTypes.Abort)
+ {
+ return;
+ }
+ }
+ else
+ {
+ StorageFolder pastedFolder = await CloneDirectoryAsync(item.Path, destinationPath, item.Name, false);
+ CurrentInstance.ViewModel.AddFolder(pastedFolder.Path);
+ pastedItemPaths.Add(pastedFolder.Path);
+ }
}
else if (item.IsOfType(StorageItemTypes.File))
{
diff --git a/Files/MultilingualResources/Files.de-DE.xlf b/Files/MultilingualResources/Files.de-DE.xlf
index 69f407eac293..18ca7fc7963d 100644
--- a/Files/MultilingualResources/Files.de-DE.xlf
+++ b/Files/MultilingualResources/Files.de-DE.xlf
@@ -427,7 +427,27 @@
Einstellungen
+
+
+ This action cannot be done
+
+
+
+ The destination folder
+
+
+
+ is a subfolder of the source folder
+
+
+
+ Skip
+
+
+
+ Cancel
+