|
I have the following xml file (snippet only:
The course hierarchy is represented in a treeview while the course title is the root and the subjects of the lessons are the nodes. I'm trying that each time the user selects a lesson (click on a node in the treeview), the corresponding file will be opened - according the text of the <file> that is in the same context as of the selected lesson's subject.
In order to open the file I'm using "process":
| | public void OpenFile1(string fileName, XmlDocument doc) { Process process = new Process(); try { string courseDocumentsPath = null; XmlNode node = doc.SelectSingleNode("/course/module/@location"); courseDocumentsPath = node.Value; if(courseDocumentsPath == null) { MessageBox.Show("File doesn't exist"); } else { process.StartInfo.FileName = courseDocumentsPath + "\\" + fileName; process.StartInfo.Verb = "Open"; process.StartInfo.CreateNoWindow = true; process.Start(); } } catch (Win32Exception e) { if(e.NativeErrorCode == ERROR_FILE_NOT_FOUND) { MessageBox.Show(e.Message + ". Check the path."); } else if (e.NativeErrorCode == ERROR_ACCESS_DENIED) { MessageBox.Show(e.Message + ". You do not have permission to print this file."); } } }
|
Can someone please assist in how to open the corresponding file while selecting a specific subject?
Thanks a lot |