How can I achieve the effect of dragging an arbitrary file icon on the icon of my program? That is, I want to make it so that if I drag a file to my program, the program starts and opens this file. In the figure, MyProgram is a program in C # that I write. File is the file I want to open.
Asked
Active
Viewed 103 times
0
-
4The default effect of this is that the filename is passed as a command line argument. Check the CommandlineArgs and handle the opening on program start. – Jens Mar 26 '17 at 18:09
-
Possible duplicate of [How do I drag and drop files into an application?](http://stackoverflow.com/questions/68598/how-do-i-drag-and-drop-files-into-an-application) – ComputersAreCool Mar 26 '17 at 18:14
-
Hooray! Thanks, it's beautiful! This is what I need! :) – Dmitrii Kurylev Mar 26 '17 at 18:17
1 Answers
1
As Jens commented you may check Environment.GetCommandLineArgs
or you can just use main method arguments:
public static void Main(string[] args)
{
if (args.Length > 0)
Console.WriteLine(args[0]); // Here's the file path
}

align
- 351
- 2
- 9