-3

I have a console application that converts .txt files into .xml files. I made a WinForms application to make a menu and select a Console Application and run it. The user can choose the paths of the input files through a browse button, and it insert the paths as string into some textboxes. Now I want the Console App to read what they say so it can locate the input files. Is there any way to do this?

  • 3
    Possible duplicate of [How can I read user input from the console?](https://stackoverflow.com/questions/7280591/how-can-i-read-user-input-from-the-console) – Filnor Jan 23 '18 at 08:50
  • 1
    Because the windows forms will be build out to be a host menu for other c-sharp programs, so people with little knowledge of the programs can still use it – Owen Klijnsma Jan 23 '18 at 08:55
  • Thank you, I'll try that – Owen Klijnsma Jan 23 '18 at 09:02

2 Answers2

0

From your winform application you can launch another process (probably by passing exe path of console app you talking about and relevant i/p parameter of type string which is basically path of your text file provided by user)

This link might help you do that.

rahulaga-msft
  • 3,964
  • 6
  • 26
  • 44
0

It is pretty easy to launch a console app from a WinForms app by simply using a process. Example:

Process.Start("myConsoleApp.exe", "some arguments");

However, the only time this makes sense is when the console app is not your own code. Or if it is your own code, but it is a generic app that is called from different UIs or methods.

If none of the above is the case (which seems to be your case), it makes more sense to merge the UI and functionality in one app. You wanted the menu to be a generic app that calls different apps, so simply remove the UI related to the console app, make it a separate WinForms app, and add the code from the console app to it. Now your menu app will simply call a WinForms app that has the UI and functionality all in one. You will use the same method above, but likely you don't need to pass any arguments:

Process.Start("myWinformsApp.exe");
Racil Hilan
  • 24,690
  • 13
  • 50
  • 55