DragData Class

The data of a drag from outside the user agent (e.g. files dragged from the file manager of the operating system): the files and the directories, and the strings (e.g. the text dragged from another application). Start the drag with PointerInput.BeginDrag or drop it at once with UserInput.Drop.

public sealed class DragData

Constructors

NameDescription
DragData()

DragData()

DragData.cs
public DragData()

No documentation is available.

Properties

NameDescription
EffectAllowedGets or sets the operations that the source of the drag allows: the effectAllowed of the DataTransfer objects (none, copy, copyLink, copyMove, link, linkMove, move or all, the default).
EntriesGets the files and the directories that are dragged, in the order they were added.
StringsGets the strings that are dragged (their type, e.g. text/plain, and their data), in the order they were added.

EffectAllowed

DragData.cs

Gets or sets the operations that the source of the drag allows: the effectAllowed of the DataTransfer objects (none, copy, copyLink, copyMove, link, linkMove, move or all, the default).

public string EffectAllowed { get; set; }

Property value

string

Gets the files and the directories that are dragged, in the order they were added.

public IReadOnlyList<DragDataEntry> Entries { get; }

Gets the strings that are dragged (their type, e.g. text/plain, and their data), in the order they were added.

public IReadOnlyList<KeyValuePair<string, string>> Strings { get; }

Methods

NameDescription
AddDirectory(string)Adds an empty directory: add its files with DragDataDirectory.AddFile and DragDataDirectory.AddDirectory.
AddFile(string, ReadOnlyMemory<byte>, string?, DateTimeOffset?)Adds a file.
AddFromDisk(string)Adds a file or a directory of the disk, with its files and its subdirectories. The content is read when this method is called (a snapshot). The symbolic links to directories are not followed.
SetString(string, string)Sets the string of a type (e.g. text/plain, text/uri-list or text/html): it replaces the string of the same type.

AddDirectory(string)

DragData.cs

Adds an empty directory: add its files with DragDataDirectory.AddFile and DragDataDirectory.AddDirectory.

public DragDataDirectory AddDirectory(string name)

Parameters

name string
The name of the directory (see DragData.AddFile).

Returns

DragDataDirectory

AddFile(string, ReadOnlyMemory<byte>, string?, DateTimeOffset?)

DragData.cs

Adds a file.

public DragDataFile AddFile(string name, ReadOnlyMemory<byte> content, string? type = null, DateTimeOffset? lastModified = null)

Parameters

name string
The name of the file (it cannot contain / or \, and cannot be . or ..).
content ReadOnlyMemory<byte>
The bytes of the file (not copied).
type string?
The media type of the file, or null for the type of its extension (an empty type for an unknown extension).
lastModified DateTimeOffset?
The last modification date of the file, or null for the current time of the browsing context.

Returns

DragDataFile

AddFromDisk(string)

DragData.cs

Adds a file or a directory of the disk, with its files and its subdirectories. The content is read when this method is called (a snapshot). The symbolic links to directories are not followed.

public DragDataEntry AddFromDisk(string path)

Parameters

path string
The path of the file or of the directory.

Returns

DragDataEntry

Exceptions

FileNotFoundException
There is no file or directory at path.

SetString(string, string)

DragData.cs

Sets the string of a type (e.g. text/plain, text/uri-list or text/html): it replaces the string of the same type.

public void SetString(string type, string data)

Parameters

type string
The type of the string (it is converted to ASCII lowercase).
data string
The string.