Skip to content

Other - Native Files

A drop target can accept OS-level drags by listing a BdndNativeTypes value. The first target accepts BdndNativeTypes.File: drag files - or a folder, which ExpandDirectories opens up into the files inside it, each with its RelativePath - from your file explorer onto it, and OnNativeDrop receives the files with their name, type, size and LastModified date; the contents of the small text files are read with OpenReadStreamAsync. At most 100 files are listed (MaxFiles); TotalFileCount tells how many the drop carried, and FileListIncomplete whether a folder could not be listed in full. The second takes images only, three at most (AcceptFileTypes="image/*", MaxFiles): a drag of other files is refused while it hovers, from their MIME types, and on a drop the files of other types are left out. The third takes PDFs and text by extension and type (.pdf, text/plain): names are known only at the drop, so it takes any file drag and sorts the files out then.

Drag files here from your OS
Images only
PDFs and text
The browser hands a drop's files to the page during the drop only; the target keeps those of its last drop, so read them in OnNativeDrop or soon after. A dropped file is untrusted input: check its type and size before acting on its contents.
An unhandled error has occurred. Reload 🗙