It depends on the command line written in the file type registration. Most typically, the first parameter is used and the file with input document. You get its name using the method
System.Environment.GetCommandLineArgs()[1]
, please see:
http://msdn.microsoft.com/en-us/library/system.environment.getcommandlineargs.aspx[
^].
It's important to check up the number of command line arguments checking the length of the array returned by the function shown above — the command line may not have parameters. In all cases, the very first parameter is always a file name of a main executable module of the entry assembly of the running application.
Another method is using the parameters passed to the entry point of the application; normally, this is the
Main
method. Please see:
http://en.wikipedia.org/wiki/Main_function#C.23[
^].
For this purpose, you should use the signature with
args
and use
args[0]
(first parameter is the first parameter in the command line, not executable file name). You should always check up if the length of the array is more than zero; zero is the case of empty command line.
For a sophisticated yes easy-to-use command line setup and parsing, please see my article on the topic:
Enumeration-based Command Line Utility[
^].
—SA