• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 68
  • Last Modified:

Drag and Drop File

I am using the code below which works fine for dropping a file outside of my program.

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

What I would like to be able to do for example is if Explorer is opened up. I would like to use the mouse event to highlight a folder the user would be over and be able to drop into that. is that possible?
0
dthillsr
Asked:
dthillsr
  • 2
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
You want to highlight folder of File Explorer? You cannot. File Explorer does not allow automation.
0
 
CodeCruiserCommented:
If you indicate you dragdrop type to be file (which you are) then Explorer should automatically highlight a folder if you hover over it. Is it not doing that?
0
 
dthillsrAuthor Commented:
I do not know what I was thinking, it does do that.
0
 
dthillsrAuthor Commented:
Is there a way I can get the path information over a highlighted folder? I am using the code below to get where the mouse is but I would like to get the path of the highlighted folder.

txt = ""
        'txt &= "Position: " & MousePosition().ToString() & vbCrLf
        Dim window_handle As Integer = WindowFromPoint(MousePosition.X, MousePosition.Y).ToString()
        'txt &= "Window handle: " & window_handle & vbCrLf
        Dim root_handle As Integer = FindRoot(window_handle)
        'txt &= "Root handle: " & root_handle & vbCrLf
        'txt &= "Root text: " & vbCrLf & WindowText(root_handle) & vbCrLf
        txt &= WindowText(root_handle)
        lblInfo.Text = txt
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now