Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get file paths of items dropped onto a console application window?

I'd like to be able to let users drag and drop files onto my console app's window so they are not forced to drag'n'drop files onto the app's icon (or link, or even worse write a command line in console). How do I get the list of paths of files I drop onto my app's window?

like image 306
user1306322 Avatar asked Sep 30 '12 16:09

user1306322


People also ask

What allows the window to stay up when running a console app?

ReadLine() will keep the window open until enter is pressed, but Console. ReadLine() will only be called if the debugger is attached.

How do I run a .NET core console app on Windows?

If it's a framework-dependent application (the default), you run it by dotnet yourapp. dll . If it's a self-contained application, you run it using yourapp.exe on Windows and ./yourapp on Unix.


1 Answers

You can just listen for the keyboard. When dragging a file onto a console window the window gets keyboard events as if the file name was entered directly.

That's how you can drop a file on a cmd or PowerShell window and get the full file name as if entered directly and it works the same for your own applications too.

like image 137
Joey Avatar answered Oct 10 '22 04:10

Joey