Reputation: 189
I'm working on a console App that reads xml files, does some calculation and then provides other xml files
I show you a part of code:
static void Main(string[] args)
{
Console.WriteLine("Please provide the file name of your xml input (without the \".xml\" extention): ");
string FileName = Console.ReadLine();
string entry = null;
if (FileName == "NetworkGTCS_7" || FileName == "NetworkGTCS_6")
{
Console.WriteLine("Please Provide the level's number to reach \"Level should be between 1 to 7\"");
Console.WriteLine("N-B: if the provided level is greater than \"5\", the operation will take few minutes to generate the output file");
entry = Console.ReadLine();
}
else if .... etc
.
.
.
Console.WriteLine($"The output file \"NXRoutesFor({FileName})level{level}.xml\" is generated with success !");
Console.WriteLine("Tap \"ENTER\" key to exit...");
Console.ReadLine();
...etc
}
So as shown in the code my app receives two parameters: the first one is a file name (string) and the second one is Number (integer)
I created the following Batch file in order to launch my app :
@echo off
C:\NXRoutesCalculationApp\NXRoutesCalculation.exe NetworkGTCS_2 7
when i click on this file the console opens and shows the "WriteLine Message" .
it seems that the parameters are not taken in consideration, and no file is generated
What should I change to perform this correctly ?
Upvotes: 1
Views: 242
Reputation: 751
Well, your params are in string [] args
which is a paramerter.
Try insert this line into your code and run it.
Console.WriteLine(args[0]);
It should show you the first parameter you've entered.
So in your code change
string FileName=Console.ReadLine();
for
string FileName=args[0];
That should do the trick.
Upvotes: 2