To read console arguments from windows application in .net

V

vijay

Hello
I have started recently with developmet in c sharp

I am developing a windows application , but it some times launced from
command line with command line parameterss,,
i wanted to know , if there is any way to do this,

Would System.console,.readline() would help

tried with ths, Bu ti am gettng a null string, this says that this
function will get the next line ... what does this mean
I also tried with read, but with no success

I hope the community would help me here,
Thanks
Vijay
 
R

Reinhold Schalk

Hallo Vijay,
a windows application in .NET has the same entrypoint as a console
application.
So you can use the version of Main() with parameter string[], which
represents the command line arguments (Index 0 has the first argument).
Just use
public static void Main(string[] astrArgs) {
...
}

Hope that helps
Reinhold
 
?

=?iso-8859-15?Q?Lasse_V=E5gs=E6ther_Karlsen?=

Hallo Vijay,
a windows application in .NET has the same entrypoint as a console
application.
So you can use the version of Main() with parameter string[], which
represents the command line arguments (Index 0 has the first argument).
Just use
public static void Main(string[] astrArgs) {
...
}
<snip>

Additionally, look at Environment.GetCommandLineArgs, which can be called
from anywhere in the application. Note that this array will contain the
path+filename of the program as the 0th element.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top