Drag&Drop File Copy

Posted on 2005-04-14
Last Modified: 2010-04-16

I want to copy or move files with dragging list entry items or icons to Windows Explorer window. Most of the tutorials and code examples show how to accept dropped items, not how to drop them to the other application windows.

I have found several C++ & Win32 api examples (for an example visit but I couldn't succeeded to make a working translation yet.

Can you help me with this?

Thanking in advance...
Question by:smalkim
    1 Comment
    LVL 7

    Accepted Solution

    Dragging files onto Explorer is indeed quite complicated, especially in .NET, where objects are somewhat more complicated than simply a structured memory layout. Fortunately, System.Windows.Forms.DataObject has functionality built in especially for this:

    string[] fileNames = GetFileNamesToDrag();
    DataObject obj = new DataObject(DataFormats.FileDrop, strings);
    DoDragDrop(obj, DragDropEffects.Copy);

    Obviously, you can use DragDropEffects.Move to move instead of copy. If you specify both (DragDropEffects.Copy | DragDropEffects.Move), then Explorer will automatically determine whether it should move or copy it based on the modifier keys you're holding down (ctrl to copy, shift to move). Hope this helps.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now