S
S
Samaif2016-07-16 14:01:51
cmd/bat
Samaif, 2016-07-16 14:01:51

C# command line work?

I have not worked with the command line before, so I'm dumb. The essence of the program is this: I run the program through cmd. When I enter "Program TextFile.txt", it opens the file and everything is fine. When I enter "Program" - an error.
It is necessary to make it so that instead of an error it showed a hint "Forgot to enter a file name".

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Z
Zelimkhan Beltoev, 2016-07-16
@Beltoev

if(args == null || args.Length == 0))
  {
      Console.WriteLine("Забыл ввести имя файла");
  }

#
#algooptimize #bottize, 2016-07-16
@user004

args.Length < 1 then error
or
args.Length ==0 then error
Странно что обработать аргумент вы смогли,а проверить его наличие - нет.

L
LiptonOlolo, 2016-07-16
@LiptonOlolo

static void Main(string[] args)
{
  if (args.Length <= 0) { Console.WriteLine("args is null!"); return; }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question