728x90
C# 프로그램 (EXE 실행 파일)을 콘솔 윈도우(cmd.exe)에서 실행할 때, 실행파일 뒤에 프로그램에서 사용할 옵션들(Command-Line Argument라 부름)을 사용할 수 있다. 이렇게 지정된 옵션들은 C# 프로그램의 Main(string[] args) 메서드의 입력 파라미터인 args에 전달된다.
static void Main(string[] args)
{
int argsCount = args.Length;
if (argsCount < 2)
{
Console.WriteLine("Usage: MyApp.exe {inputFilename} {outputFilename}");
Console.WriteLine(" ex) MyApp.exe data.inp data.out");
return;
}
string inputFile = args[0];
string outputFile = args[1];
Console.WriteLine("Input File: {0}", inputFile);
Console.WriteLine("Output File: {0}", outputFile);
}
Visual Studio에서 Command Line Argument 지정하기
728x90
'C#' 카테고리의 다른 글
TableLayout에서 Label Ellipsis 사용하기 (0) | 2023.01.25 |
---|---|
[암호화] 용어 정리 (0) | 2023.01.23 |
Task cancellation (0) | 2023.01.23 |
Task Parallel Library에 대한 예외 처리2 (0) | 2023.01.23 |
Task Parallel Library에 대한 예외 처리1 - Child Task에 대한 예외 처리 (0) | 2023.01.23 |