views:

519

answers:

1

Hi,

I have a query about drag-drop in C# using .NET.

My issue is with remote files. I have a list of remote files which the user can drag into an explorer window (desktop, etc). When such a drag occurs I want to be able to download the file and write it to the drop location.

The normal method of dragging files:

private void StartDragDrop(string FileToDrag)
{
MyControl.DoDragDrop(new DataObject(DataFormats.FileDrop, FileToDrag), DragDropEffects.Copy);
}

...does not suit my needs as I will not have the file data to populate the drag-drop object until after the DROP.

I have seen this functionality in many FTP clients and such.

Thanks in advance wizards.

A: 

hi try this,

public partial class Form1 : Form { public Form1() { InitializeComponent(); this.listBox1.Items.Add("foo.txt"); this.listBox1.MouseDown += new MouseEventHandler(listBox1_MouseDown); this.listBox1.DragOver += new DragEventHandler(listBox1_DragOver); }

void listBox1_DragOver(object sender, DragEventArgs e)
{
    e.Effect = DragDropEffects.Copy;
}

void listBox1_MouseDown(object sender, MouseEventArgs e)
{
    string[] filesToDrag = 
    {
        "c:/foo.txt"
    };
    this.listBox1.DoDragDrop(new DataObject(DataFormats.FileDrop, filesToDrag), DragDropEffects.Copy);
}

}

Emmad
Read the question...
ThePower