exe file geting a parameter from the command lie

  • Thread starter Thread starter rodrigo guerra
  • Start date Start date
R

rodrigo guerra

i need a exe file that will take a parameter from the command line and
launch the default application that the user has to plays a video file (the
param from command file). and then the exe files finishes.

is that possible. ? how can i do it ? links? articles ?

thanks!
 
rodrigo guerra said:
i need a exe file that will take a parameter from the command line and
launch the default application that the user has to plays a video file (the
param from command file). and then the exe files finishes.

is that possible. ? how can i do it ? links? articles ?

Getting parameters from the command line is easy - just make your Main
method take a string array as an argument. For instance:

using System;

class Test
{
static void Main (string[] args)
{
Console.WriteLine ("{0} arguments provided:");
foreach (string arg in args)
{
Console.WriteLine (arg);
}
}
}
 
Apologies, there was a bug in my code. This line:
Console.WriteLine ("{0} arguments provided:");

should have read:

Console.WriteLine ("{0} arguments provided:", args.Count);
 
hi jon, thanks for the feedback.

but what about the second part ?
take this parameter (will be a string from a video file "myVideo.mpeg" and
launching in the user´s default player. it would be difficult to do this ?

thanks!
 
rodrigo guerra said:
i need a exe file that will take a parameter from the command line and
launch the default application that the user has to plays a video file (the
param from command file). and then the exe files finishes.

is that possible. ? how can i do it ? links? articles ?

thanks!

Running the default associated program is also easy..

Use the System.Diagnostics.Process class.. Then set the StartInfo to the
name of the file you want to run then it'll start the correct exe for that
file.

Simon.
 
rodrigo guerra said:
but what about the second part ?
take this parameter (will be a string from a video file "myVideo.mpeg" and
launching in the user´s default player. it would be difficult to do this ?

Look at System.Diagnostics.Process. I can't remember offhand whether
you need to explicitly use something to do the equivalent of "start"
under the command prompt, or whether you can just give the filename -
either way, it may well not work on 98.
 
thanks for the System.Diagnostics.Process class tip, i´m gonna look for it.

[]´s rodrigo.
 
Back
Top