Hello, I am working on a simple application that I have ran into a snag. Currently I have a listbox being populated from a network directory.
DirectoryInfo dinfo = new DirectoryInfo(@"N:\Support Teams\Information Technology\Documents\Guides\KB\"); FileInfo[] Files = dinfo.GetFiles("*.*"); foreach (var file in dinfo.GetFiles("*", SearchOption.AllDirectories)) { listBox1.Items.Add(file.Name); }
Which works fine. The directory has a tree of folders that contain documents; so the search function was added to accommodate for this.
The issue I am having is trying to open the files from the list.
private void button1_Click(object sender, EventArgs e) { string file = listBox1.SelectedItem.ToString(); string fullFileName = Path.Combine(@"N:\Support Teams\Information Technology\Documents\Guides\KB\", file); //Process.Start(fullFileName); MessageBox.Show("" + fullFileName); }
I was using a messagebox to help figure out the issue I was having, and as you can tell; it's not recognizing the folder the file is in. How can I get Process.Start to read the full path of the file trying to be open, so it will actually open the file?
Thanks!