Click here to Skip to main content
15,908,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi How can i find file address of one file that dragged to a form ?

thanks a lot and have a good day ?
Posted
Comments
RDBurmon 6-Feb-12 3:31am    
Hello Mohammad ,

I hope you got your answer. But one suggestion while posting question in forum in future please try to specify language(Vb.net,C# ETC..) you are using.

Try:

C#
private void frmMain_Load(object sender, EventArgs e)
    {
    AllowDrop = true;
    DragEnter += new DragEventHandler(frmMain_DragEnter);
    DragDrop += new DragEventHandler(frmMain_DragDrop);
    }
void frmMain_DragEnter(object sender, DragEventArgs e)
    {
    if (e.Data.GetDataPresent(DataFormats.FileDrop))
        {
        // File - is fine
        e.Effect = DragDropEffects.Copy;
        }
    else
        {
        // Unknown data, ignore it
        e.Effect = DragDropEffects.None;
        }
    }
void frmMain_DragDrop(object sender, DragEventArgs e)
    {
    string[] files = (string[])e.Data.GetData(DataFormats.FileDrop, false);
    foreach (string file in files)
        {
        Console.WriteLine(file);
        }
    }
 
Share this answer
 
Comments
RDBurmon 6-Feb-12 3:29am    
Good code, My +4
mohammadghaderian.bp 13-Feb-12 10:37am    
thanks a lot man
Read this

Drag and Drop files from Windows Explorer to Windows Form[^]

Hope this helps , if yes then accept and vote the answer otherwise revert back with your queries
--Rahul D.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900