Reputation: 95
I currently have the following set up:
namespace TSRVTC_GUI
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnselect_Click(object sender, EventArgs e)
{
FolderBrowserDialog fdb = new FolderBrowserDialog();
if (fdb.ShowDialog() == System.Windows.Forms.DialogResult.OK)
txtpath.Text = fdb.SelectedPath;
}
private void btnlaunch_Click(object sender, EventArgs e)
{
Process.Start(@"fdb\Launcher.exe");
}
}
}
I am trying to start a program contained within a different directory to the .exe but this doesn't work, if someone could help me I'd appreciate it.
I also apologize for the back structure of this question but I am still new on here.
Upvotes: 0
Views: 81
Reputation: 62498
You can use Text
property of txtpath
instance of TextBox
as you are setting the Path in it from FolderBrowseDialog
instance, you can do it like:
Process.Start(txtpath.Text);
and if the path is without executable name then you will have to write like:
Process.Start(txtpath.Text+"\launcher.exe");
or more better is to use Path.Combine
:
Process.Start(Path.Combine(txtpath.Text,"launcher.exe"));
and for able to use Path
class, you would need to add using System.IO
in the usings of your class.
Hope it helps!
Upvotes: 3