Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: Drag & Drop File on .exe (icon) and get filepath

I'm new to C# and I'm not getting around this trouble. Here is what I wanted to achieve. Whenever I drag and drop a file on the .exe file (on the icon itself), the application should capture the filepath of dragged file.

Thanks.

like image 493
Praveen Avatar asked Dec 15 '22 14:12

Praveen


1 Answers

If I understand correctly, you want to drop a file onto an icon of an exe, not an application itself. If that is so, it can be achieved easily using the parameters passed into the application. If you check your original boilerplate code when you make a console application it has the application entry point:

static void Main(string[] args)

If you drag drop a file onto the icon of the application, the args[0] will hold the name of the file being dropped. If the goal is to drop the file onto an EXE file, there are numerous tutorials on SO about that.

like image 182
Andrej Kikelj Avatar answered Dec 26 '22 10:12

Andrej Kikelj