0

I have a program with a simple text box and button (at the moment).

The user will either enter/select the file from a dialog.

The user will enter a given file path, and when you press the 'EXECUTE' button, the program will attempt to open/run this file/executable?

what is the best way about achieving this? I'm fairly novice and so am not entirely sure what all the 'lingo' is?

PS. I have looked at google for examples, but the code never seemed to actually 'DO' anything?

Any help much appreciated.

btnExecute


string myFile = MyfilePath.Text

Also, is there anyway of checking if the file exists/lets them select it instead of typing it into the textbox?

Is there anyway of ensuring the file is 'openable'?

  • As for your second question, see [How to: Use the Open File Dialog Box](http://msdn.microsoft.com/en-us/library/cc221415(v=vs.95).aspx). Try to search the web and this site before asking, and explain what exactly you tried and what didn't work. – CodeCaster Aug 15 '14 at 08:41
  • to be honest, I didn't know where to start. I was trying to second guess what i should be looking for (i.e. trying to type 'run' into VS) but that obv. didn't work –  Aug 15 '14 at 09:11
  • It's easier to search the web for what you are trying to do ("C# run program" will show plenty of results) instead of trying to guess function or class names. :) – CodeCaster Aug 15 '14 at 09:12
  • 1
    Ok thank you for your help CodeCaster. –  Aug 15 '14 at 09:15

1 Answers1

0

You can use Process.Start Method to run executables from your code.

System.Diagnostics.Process.Start(myFile);

nsgocev
  • 4,390
  • 28
  • 37