Draging SFTP file from listview

I have a program created so far that will display the contents of a users default directory on our SFTP site in a listview box. What I need to do though is to be able to frag the file from the listview box to wherever the user wants to drag it to such as their desktop or documents folder. I am using the code below using a mouse double click for testing to download the file using a folderbrowserdialog.

If lstvSFTPFiles.SelectedItems.Count > 0 Then
            Dim strFilesPath() As String
            ReDim strFilesPath(lstvSFTPFiles.SelectedItems.Count - 1)
            For i As Integer = 0 To lstvSFTPFiles.SelectedItems.Count - 1
                strFilesPath(i) = lstvSFTPFiles.SelectedItems(i).Text
                DownloadFile(lstvSFTPFiles.SelectedItems(i).Text)
            Next
            Dim dt As DataObject = New DataObject(DataFormats.FileDrop,
            strFilesPath)
End If

I need to drag and drop outside the program. Is there a way to get the path where a user would drag a file too that I could send back to the program to complete the download? et me know if there is other code you would need to see.
dthillsrAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
Are you asking how to access the SFTP site to get the file, and then the user would have it available as file drop content?
dthillsrAuthor Commented:
I already have the file displayed in a listview box from the sftp site. I am looking for a way for a user to be able to drag the file from the listview box and drag to the desktop or documents folder. If I can just get the path information of where the user would drop it, I can make the code work the way I have it set up so far.
Bob LearnedCommented:
I don't think that it can work that way.  With file drag and drop, you need to provide the file drop contents, and the target application can process it accordingly.

Here is an example of how a VB.NET application would handle the file drop:

Private Sub Form1_DragDrop(sender As System.Object, e As System.Windows.Forms.DragEventArgs) Handles Me.DragDrop
    Dim files() As String = e.Data.GetData(DataFormats.FileDrop)
    For Each path In files
        MsgBox(path)
    Next
End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dthillsrAuthor Commented:
I was suspecting this would be the case. I have been able to drag and drop to the desktop from a listview box with an actual file. I know the file I am trying to drag now is more like a virtual file in the listview box since only the name of the file exists there and the file is actually still on the sftp site.
Bob LearnedCommented:
When you start the drag operation, the data takes a string array, so the files need to exist for the paths in the string array.

http://www.codeproject.com/Articles/14059/Drag-and-drop-cut-copy-and-paste-files-with-Window

Dim files As String() = GetSelection()
DoDragDrop(New DataObject(DataFormats.FileDrop, files), 
                   DragDropEffects.Copy | DragDropEffects.Move)

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.