Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this application that lists files in a WindowsForms listbox (NET framework). The application does not support the copy operation if multiple files are selected in the listbox, but at the same time, the application supports 'drag and drop' event for multiple files (allows dragging the files 'out of the application').

How can I extract the paths of the files 'dragged out of the application'? (i.e. I drop the files on some program / script that shows me the paths / saves the paths to a txt file).

share|improve this question
up vote 1 down vote accepted

The bat script will work with up to about 15 files, because of the limitation of the cmd.exe:

@echo off 
if "%~1"=="" goto end
echo %1
goto getfile


Autohotkey script that bypasses the limitation:

; The script displays the file paths. File paths that were
; dropped onto the Text control. AHK Text control. AHK Text control
; that is part of this AHK script.
; The script bypasses the ~2048 cmd.exe input parameters character limitation.
; See here for more info:
Gui, Add, Text, vText1 h80, Drag files here
Gui, Show


    MsgBox, % "A_GuiControl=" A_GuiControl "`n" ; on what AHK control were files dropped
            . "A_EventInfo=" A_EventInfo "`n"   ; number of files
            . "A_GuiEvent =" A_GuiEvent         ; all filenames, divided by `n
share|improve this answer
There is no windows limitation for 15 files. Would it make sense there there is something else going on with the program? Also, what is the error? – soandos Jun 13 '12 at 0:42
"Windows cannot access the specified device, path, or file. You may not have the appropriate permissions to access the item." The error shows up even if I drag the files onto an empty .bat script. – colemik Jun 13 '12 at 8:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .