Link to home
Start Free TrialLog in
Avatar of josephdts
josephdts

asked on

Parameters in C++/CLI

I need to pass parameters in the C++/CLI Console application like :Input File, Output File, Log File location. I would like to do it using array<String^>^args = Environment::GetCommandLineArgs();
However, nothing is being passed from the console. There are a number of code examples in msdn, but they do not show how to input the arguments from the console.  For example:
int main()
{
   array<String^>^args = Environment::GetCommandLineArgs();
   const int tabSize = 4;
   String^ usageText = "Usage: INSERTTABS inputfile.txt outputfile.txt";
   StreamWriter^ writer = nullptr;
   if ( args->Length < 3 )
   {
      Console::WriteLine( usageText );
      return 1;
   }

   try
   {
      // Attempt to open output file.
      writer = gcnew StreamWriter( args[ 2 ] );
      // Redirect standard output from the console to the output file.
      Console::SetOut( writer );
      // Redirect standard input from the console to the input file.
      Console::SetIn( gcnew StreamReader( args[ 1 ] ) );
   }
ASKER CERTIFIED SOLUTION
Avatar of josephdts
josephdts

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of onlyforchrist
onlyforchrist

i want to learn about microsoft c++. please how can i get started?