0

Okay. This looks impossible, but since lot of programs have this kind of functionality, I want to know how. So, here's the deal. I have a program that loads files that exist on the computer into a ListView control. I can insert files into ListView by dragging them from Windows Explorer. Problem is, how do I export files from my ListView to Windows Explorer. I went through a lot Stackoverflow questions, lot of forum threads and still didn't find solution. I only need to know how to get the path of the object where I dropped the item. For example, I dragged my item from ListView and dropped it onto Windows Explorer window. How do I get the path of the folder that's opened by that window?

I am sorry if I didn't describe my question well.

TheNeosrb
  • 89
  • 1
  • 2
  • 10
  • 2
    I think this is the solution to your problem [Drag and drop to Explorer using DoDragDrop][1] [1]: http://stackoverflow.com/questions/3040415/drag-and-drop-to-desktop-explorer – sevi Sep 17 '14 at 15:33
  • It's not. I only need the path of where the file is dropped. Just one string containing the path. @sev – TheNeosrb Sep 17 '14 at 15:37
  • Why do you need the path of the target folder? – Denis Anisimov Sep 17 '14 at 16:41
  • So I can use `File.Copy(PathToWhereMyFileIs, PathOfWhereTheFileIsDropped);` @DenisAnisimov – TheNeosrb Sep 17 '14 at 16:44
  • In normal case Explorer or any other app supports drag&drop copy files by themselves. The only things you need to do - create correct IDataObject with filenames (for example with using of CF_HDROP format) and DROPEFFECT_COPY value stored in CF_PREFERREDDROPEFFECT format. Why do you want to copy files manually? – Denis Anisimov Sep 17 '14 at 16:55
  • Because I don't know how to do it the way you described. @DenisAnisimov – TheNeosrb Sep 17 '14 at 17:06
  • Link in the first comment describes all necessary procedures. And there is NO way to know target path in common case. – Denis Anisimov Sep 17 '14 at 17:12

1 Answers1

0

I found this webpage which shows you how to get the path of an Explorer or Internet Explorer Window. This doesn´t give you the path to the specific directory you´ve dropped the files to but it gives you one or more directories which you could check for the existense of the file.
When you find an open instance of Windows Explorer where your file exists, you´ve got the directory where it was dropped to.

Another approach could be to try to hook up to the copy process and get the TargetPath from there. I suspect this would need you to write a file system filter driver which is a lot of work.

sevi
  • 460
  • 5
  • 20