Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
2.6k views
in .NET FTP by (120 points)
Is it possible to drag selected files from the FTPRemoteFileList to a standard ListView?

1 Answer

0 votes
by (51.6k points)
Yes or no depending on the details.

Yes, if the form containing the target ListView has access to the source ExFTPConnection (or SecureFTPConnection). No, if it isn't.

If you're in the former category then what you need to do is to implement drag-drop the way you normally would. The data type is DataFormats.Text. The text consists of a list of paths separated by ';' and with each item prefixed with an 'F' if it's a file and 'D' if it's a directory. Here's some code that you can put in your DragDrop handler:
object o = e.Data.GetData(typeof(string));
string fileList = (string)e.Data.GetData(typeof(string));
if (fileList != null && fileList.Length > 0)
{
    foreach (string i in fileList.Split(';'))
    {
        bool isDir = i.Length > 0 && i[0] == 'F';
        string file = i.Substring(2);
        string path = Path.Combine(LocalDirectory, file);
        if (isDir)
            ftp.BeginDownloadFile(path, file, null, null);
        else
            ftp.BeginDownloadMultiple(path, file, "*", true, null, null);
    }
}

'e' is the DragEventArgs object passed to the handler and 'ftp' is the ExFTPConnection.

- Hans (EnterpriseDT)

Categories

...