DesktopFileDropEventArgs class

Namespace Runic.Desktop in Runic.Desktop 0.23.0

public sealed class DesktopFileDropEventArgs : EventArgs

Inherits or implements EventArgs.

Provides the files the user dropped onto a window, for DesktopWindow.FilesDropped.

Constructors

DesktopFileDropEventArgs

public DesktopFileDropEventArgs(IReadOnlyList<string> paths, string? target = null)

Creates event data for dropped files.

Parameters

paths

The absolute local paths of the dropped files and directories, as the platform reported them.

target

The page's routing label, or null; see DesktopFileDropEventArgs.Target.

Exceptions

ArgumentException

paths is empty, or contains an empty or relative path.

DesktopFileDropEventArgs

public DesktopFileDropEventArgs(IReadOnlyList<string> paths, IReadOnlyList<IReadFileLease> promisedFiles, string? target)

Creates event data for a drop that may include files without a local path.

Parameters

paths

The absolute local paths of the dropped files and directories; may be empty when promisedFiles is not.

promisedFiles

The dropped files that had no local path, as read leases; see DesktopFileDropEventArgs.PromisedFiles.

target

The page's routing label, or null; see DesktopFileDropEventArgs.Target.

Exceptions

ArgumentException

Both lists are empty, paths contains an empty or relative path, or promisedFiles contains null.

Properties

Effect

public DesktopDragEffects Effect { get; init; }

Gets what the drop performed: DesktopDragEffects.Copy, DesktopDragEffects.Move or DesktopDragEffects.Link.

Exceptions

ArgumentOutOfRangeException

The value is not exactly one of Copy, Move or Link.

Remarks

The effect the drag source and the page agreed on, from the drag source's allowed effects, the user's modifier keys and the page's data-runic-drop-effect attribute or dropEffect. DesktopDragEffects.Copy by default. On WebView2 the page reports it, so it is as untrusted as DesktopFileDropEventArgs.Target: use it to choose between copying and moving the user's files into the application, never for an access decision.

InSidePanel

public bool InSidePanel { get; init; }

Gets whether the files were dropped onto the window's side panel rather than its page.

Remarks

false for a drop onto the page. A drop onto the side panel's page (DesktopWindow.OpenSidePanelAsync) reaches the same DesktopWindow.FilesDropped event with the same rules: native paths, the panel page's DesktopFileDropEventArgs.Target label and DesktopFileDropEventArgs.Effect. Unlike DesktopFileDropEventArgs.Target, the native window sets it, from the view that received the drop, so it is trusted.

Paths

public IReadOnlyList<string> Paths { get; }

Gets the absolute local paths of the dropped files and directories, in the order the platform reported them.

Remarks

They come from the native window, never from the page. In a Flatpak sandbox they are document-portal paths under /run/user/<uid>/doc, which the application can open; in a macOS App Sandbox the drop grants access to them while the application runs.

PromisedFiles

public IReadOnlyList<IReadFileLease> PromisedFiles { get; }

Gets the dropped files that had no local path, such as a mail attachment, each as a read lease.

Remarks

Empty unless the platform delivered promised content: on macOS a file promise (NSFilePromiseReceiver), which Runic receives into a private staging directory. Read each lease once with IReadFileLease.OpenReadAsync; disposing it deletes the staged copy. A lease that no handler disposes stays until the process ends, so dispose every lease of the drop, opened or not, when done with it.

DesktopFileDropEventArgs.Paths may be empty when this list is not.

Target

public string? Target { get; }

Gets the data-runic-drop-target attribute of the nearest element under the drop that has one, or null when there is none or the page did not report it.

Remarks

The page reports it, so treat it as an untrusted routing label, such as which folder of a list the files were dropped on: never as a path, and never for an access decision.