473,386 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Passing Parameters to Console Application

How would I pass parameters to a console application? I would like to do
something like this:

consoleapp.exe /o \\fileshare\origindirectory /d
\\fileshare\destinationdirectory

I'm not sure how to start the console app to read from the command line.
Any assistance would be appreciated!

Michael Hetrick
Nov 13 '05 #1
1 18253
Thanks - it was the part about the args[] in Main!

"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message
news:43********************************@4ax.com...
On Tue, 15 Jul 2003 20:59:43 -0400, "Michael Hetrick"
<m1******@gc.com> wrote:
How would I pass parameters to a console application? I would like to do
something like this:

consoleapp.exe /o \\fileshare\origindirectory /d
\\fileshare\destinationdirectory

I'm not sure how to start the console app to read from the command line.
Any assistance would be appreciated!

Michael Hetrick


I'm a little unsure what you are asking...

If you are asking how to start a console program from another .NET
program (with or without parameters), use the Process class. You can
set up the name of the exe to run, parameters, etc.

If you are wondering how to handle parameters passed to a .NET console
program, they are already parsed for you via the args[] in the main
function. Each parameter is in the array and I believe the arguments
are split on white space. So, given your above command line, args[0]
would contain /o, args[1] would contain \\fileshare\origindirectory,
etc.

There may be an issue however, if your directory path contains one or
more spaces in it. Then it may split that argument into separate
arguments where the spaces exist and you'd have to piece it back
together.

If neither of these answers your question, then either someone who
understood your question better will answer or you can post a more
specific question.

Jonathan Schafer

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Andy | last post by:
Hi Could someone clarify for me the method parameter passing concept? As I understand it, if you pass a variable without the "ref" syntax then it gets passed as a copy. If you pass a...
3
by: AndyDunning | last post by:
Hello, I'm interested in establishing the best way to pass information between a vb script and a .net application. We have a VbScript that runs on a users pc every time a phone call is routed...
7
by: Ken Allen | last post by:
I have a .net client/server application using remoting, and I cannot get the custom exception class to pass from the server to the client. The custom exception is derived from ApplicationException...
1
by: Darsin | last post by:
Hi all, I am a new programmer to C# and i am having a following problem. I want to make a single method which takes a variable length array and display it contents. i have defined the method as:...
13
by: Maxim | last post by:
Hi! A have a string variable (which is a reference type). Now I define my Method like that: void MakeFullName(string sNamePrivate) { sNamePrivate+="Gates" }
1
by: kplkumar | last post by:
I am trying to get the method and the parameters passed to that method from the stackTrace. My code is, private void GetExecutingMethodInfo() { StackTrace trace = new StackTrace(false); ...
3
by: Alex | last post by:
Hello, I'm wroting a console utility in VB 2005, and I need the ability to pass parameters to the application when the program runs. For example, if my program is called testing.exe, I need to...
1
by: =?Utf-8?B?U3Jpaw==?= | last post by:
Hi, I have a console application which needs to be run at periodic intervals. So, I want to add it in Windows Task Scheduler but at the same time, I need to pass parameters to the Application...
1
by: ramjannu | last post by:
How would I pass parameters to a console application? I'm not sure how to start the console app to read from the command line.
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.