"Go" c#.net drag to get the file path

Source: Internet
Author: User

C#.net drag-and-drop implementation to get file path
Author Attilax, Email:[email protected]

Idea: Get the "info" dragged into the window via the DragEnter event (which can be several files, some text, etc.),
The "information" is parsed in the DragDrop event.


The AllowDrop property of the form must be set to true;


and must have a DragEnter event (separate write DragDrop event is not drag-and-drop function)

 Private voidForm1_dragenter (Objectsender, DragEventArgs e) {              if(E.data.getdatapresent (dataformats.filedrop)) E.effect= Dragdropeffects.link;//Important code: Indicates a link type of data, such as a file path               ElseE.effect =DragDropEffects.None; }         Private voidForm1_dragdrop (Objectsender, DragEventArgs e) {               stringPath = ((System.Array) e.Data.GetData (DataFormats.FileDrop)). GetValue (0).             ToString ();           MessageBox.Show (path); }
View Code

Reference:


WinForm Mouse drag and drop function (C #)
Drag-and-drop operations in C #-[email protected]-blog-netease blogs. htm
WinForm (C #) Drag and drop implementation to get the file path _. NET Tutorial Network--Simple and professional. NET technology Web site. htm

Original link: http://blog.csdn.net/attilax/article/details/8795867

"Go" c#.net drag to get the file path

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.