Make drag-and-drop follow Windows Explorer and refresh the tree after folder operations.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -31,8 +31,36 @@ public sealed class FileOperationService
|
||||
public Task MoveAsync(IReadOnlyList<string> sources, string destinationDirectory, CancellationToken cancellationToken = default)
|
||||
=> _queue.EnqueueMoveAsync(sources, destinationDirectory, cancellationToken);
|
||||
|
||||
public Task DeleteAsync(IReadOnlyList<string> paths, CancellationToken cancellationToken = default)
|
||||
=> _queue.EnqueueDeleteAsync(paths, cancellationToken);
|
||||
public Task DeleteAsync(IReadOnlyList<string> paths, bool permanent = false, CancellationToken cancellationToken = default)
|
||||
=> _queue.EnqueueDeleteAsync(paths, permanent, cancellationToken);
|
||||
|
||||
public Task CreateShortcutsAsync(IReadOnlyList<string> sources, string destinationDirectory, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
foreach (var source in sources)
|
||||
{
|
||||
var dest = UniqueShortcutPath(destinationDirectory, PathRules.GetFileName(source));
|
||||
if (!_shell.CreateShortcut(source, dest, out var error) && error is not null)
|
||||
{
|
||||
throw new IOException(error);
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private static string UniqueShortcutPath(string directory, string sourceName)
|
||||
{
|
||||
var stem = sourceName + " - Shortcut";
|
||||
var dest = Path.Combine(directory, stem + ".lnk");
|
||||
var i = 2;
|
||||
while (File.Exists(PathRules.ToExtended(dest)) || Directory.Exists(PathRules.ToExtended(dest)))
|
||||
{
|
||||
dest = Path.Combine(directory, $"{stem} ({i++}).lnk");
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
public void Rename(string path, string newName)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user