in sources/Google.Solutions.Mvvm/Controls/FileBrowser.cs [568:661]
internal IEnumerable<FileInfo> GetPastableFiles(
IDataObject dataObject,
bool promptForConflicts)
{
//
// Extract file paths, ignore directory paths.
//
var files = GetPastableFiles(dataObject);
if (!promptForConflicts)
{
return files;
}
//
// Allow user to exclude files that would otherwise be overwritten.
//
Debug.Assert(this.currentDirectoryContents != null);
Debug.Assert(this.currentDirectoryContents!.Count == this.fileList.Items.Count);
var result = new List<FileInfo>();
foreach (var file in files)
{
var conflictingItem = this.currentDirectoryContents
.FirstOrDefault(f => f.Name == file.Name);
var dialogResult = DialogResult.OK;
if (conflictingItem != null && !conflictingItem.Type.IsFile)
{
//
// There is an existing directory with the same name
// as the file to be dropped.
//
var parameters = new TaskDialogParameters(
"Copy files",
$"The destination already has a directory named '{conflictingItem.Name}'",
string.Empty)
{
Icon = TaskDialogIcon.Error
};
parameters.Buttons.Add(new TaskDialogCommandLinkButton(
"Skip this file",
DialogResult.Ignore));
parameters.Buttons.Add(TaskDialogStandardButton.Cancel);
dialogResult = this.TaskDialog.ShowDialog(this, parameters);
}
else if (conflictingItem != null)
{
//
// There is an existing file with the same name
// as the file to be dropped.
//
var parameters = new TaskDialogParameters(
"Copy files",
$"The destination already has a file named '{conflictingItem.Name}'",
string.Empty)
{
Icon = TaskDialogIcon.Warning
};
parameters.Buttons.Add(new TaskDialogCommandLinkButton(
"Replace the file in the destination",
DialogResult.OK));
parameters.Buttons.Add(new TaskDialogCommandLinkButton(
"Skip this file",
DialogResult.Ignore));
parameters.Buttons.Add(TaskDialogStandardButton.Cancel);
dialogResult = this.TaskDialog.ShowDialog(this, parameters);
}
switch (dialogResult)
{
case DialogResult.OK:
result.Add(file);
break;
case DialogResult.Ignore:
//
// Skip this file.
//
break;
case DialogResult.Cancel:
return Array.Empty<FileInfo>();
}
}
return result;
}