Bill
Bill

Reputation: 11

Can a C# Console App Contain Multiple Sub or Child Console Apps?

I'm not sure if what I was to do is possible. I'm not a C# guru but I manage to make a living. Over the years I've written and accumulated dozens of console apps that perform otherwise tedious tasks. Everything from cleaning junk data from SQL Server databases, changing filenames in a defined directory, creating zip archives and sending emails.

Most of the apps are built on .Net Framework 4.7. What I'm wondering is if there is a way I can combine all of these apps into a single console application? I would want it to have some sort of menu of available commands as well as descriptive help section for each command and its arguments.

Can I do this? Any tutorials come to mind? Thanks!

Upvotes: 0

Views: 79

Answers (2)

user8829594
user8829594

Reputation:

why don't you use parallel and multi-tasking instead of run multi-app? You can run multi-task.

Upvotes: 0

Mikael
Mikael

Reputation: 982

You can right click the Solution in the Solution Explorer in VS and add a project, then in your main call them based on conditions like:

using (var process1 = new Process())
{
    process1.StartInfo.FileName = @"..\..\..\ConsoleApp1.exe";
    process1.Start();
}

using (var process2 = new Process())
{
    process2.StartInfo.FileName = @"..\..\..\ConsoleApp2.exe";
    process2.Start();
}

Console.WriteLine("We Just ran two console apps inside of a console app ;)");
Console.ReadKey();

Upvotes: 1

Related Questions