i have the following code. i need to do this:
public void Window1()
{
InitializeComponent();
opendirectory();
}
public void opendirectory()
{
Stream checkStream = null;
Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();
openFileDialog.Multiselect = false;
if ((bool)openFileDialog.ShowDialog())
{
try
{
if ((checkStream = openFileDialog.OpenFile()) != null)
{
// i need the following code to be stored as a string
string antcbatchlocation = openFileDialog.FileName;
}
}
catch (Exception ex)
{
System.Windows.MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
}
}
else
{
System.Windows.MessageBox.Show("Problem occured, try again later");
}
}
then i will use that string in a later button event:
public void BuildButton_Click(object sender, RoutedEventArgs e)
{
System.Diagnostics.Process runantc = new System.Diagnostics.Process();
runantc.StartInfo.FileName = antcbatchlocation;
}
Perhaps something is wrong with this string as a variable. Seems to be like string antcbatchlocation is declared local variable. If so how should i go about fixing it? Please help thanks!