我有路径。listbox
我想在listbox
项目单击时打开文件。
我正在使用SelectedIndexChanged
,从中我可以知道被点击的项目。现在,我想打开它。
public void OpenDialogBox()
{
Stream myStream = null;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "*YOURTEXTBOX.text";
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
try
{
if ((myStream = openFileDialog1.OpenFile()) != null)
{
//Do something with Open File
}
}
catch (Exception ex)
{
// You messed up
}
}
}