-1

When the user drops a file icon on top of my application's icon, I am able to retrieve the filepath of the dropped file. It is contained in args[0].

How can I retrieve that filepath when there is no Main()?

IOW: My latest app is not console-based.

7
  • 1
    How is your app being started if it doesn't have a Main()?
    – heavyd
    Mar 3, 2014 at 18:55
  • How do you have a working C# program with no Main()? Mar 3, 2014 at 18:56
  • @heavyd Apparently I'm not the only confused one. :) Mar 3, 2014 at 18:56
  • 1
    "You have to have a Main()": That is only true for console-based applications. WPF and other types do not have a Main(). Mar 3, 2014 at 19:11
  • 1
    Just couldn't resist... For WPF the "Main" is hidden in auto-generated obj\Debug\App.g.i.cs or obj\Release\App.g.i.cs files. There is always a "Main" or another static entry point :-)
    – Nasir
    Mar 3, 2014 at 20:19

1 Answer 1

1

You can use the Environment.GetCommandLineArgs() function to get the command line arguments at any time in your application.

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