How to make a command line caller in C#?

Making things like command line program is not hard,but it's not easy either.
You have to know a lot about methods,classes,inheritance and also know how to use specific keywords and values such as IF,ELSE,CATCH,STRING,INT,FLOAT,SWITCH,VOID blablabla...

The biggest problem might be to be ready for everything in the case if the user(s) write something wrong without letting the program to crash because you never know what user(s) might do.

For example if you want to program your own command with which the user can copy a file,the first thing you need to take into the consideration is HOW will you call your OWN commands.For example "COPYFILE" and after that you also need to program the second section which is the SOURCE and DESTINATION path and at the end you must also program your own function which will handle the file copy operation.It is usually good to make your own method which handles that so every time you need it,just call it otherwise you will need to write the operation function every time you need it.

Ok let's say you want to make the command for copying the file.The most simple way for you would be to do it in 4 parts:

Part 1: Create a text box control and use it ONLY for the name of your command.Such as "COPYFILE".

Part 2: Create a second text box control and use it to write the SOURCE path location of the file which the user wants to copy.

Part 3: Create a third text box control and use it to write the DESTINATION path location where the user would like the file to be copied to.

Part 4: This is optional.It depends on you.You can give the user(s) an option to replace or to not replace the file if the new copied file contains the same name as the old file.You can of course call those commands also however you want.For example "REPLACETRUE" would replace the old file with the same name and "REPLACEFALSE" would not replace the file with the same name.


However giving the names to your own commands is the easiest part.The hard part is to PROGRAM those functions.In the above example I used "COPYFILE","REPLACE TRUE" and "REPLACE FALSE".
You will need to program and write the programming code for EACH of those 3 things.
Now HOW will you do that such as wether using methods,classes or just statements in the events or some other way...it really depends on you.

But before you do any of this,you NEED to learn the basics of C# and many other things otherwise you will not be able to make something like this especially if your own command line program will contain MANY things.
Believe me this is harder than it looks like.

Anyway if you know C# good then good luck.It's going to be a long road!

I would like to help you,but I am in the hospital right now because I will have a small local surgery on mandibula in thursday this week,but it might be in tuesday evening if I get lucky enough so and I am writing this from my laptop using wireless USB stick.

Anyway hopefuly until thursday I will come home from the hospital and I will be able to help you out.



Cheers and good luck!
 
go to main() function to retrieve switches of command line, all of c# program has this feature, and then you can run the code base on which switches was specified.
 
Back
Top