Not sure if anyone can help. I have writen some code that will allow users to edit a txt file (it's actually an xml file) in notepad. I can get notepad to open correctly with the correct file, but once changes have been made and you want to save the file it errors with "Cannot create the Locations.xml file. Please check that the filename and path are correct. I have checked these and they seem fine. It would seem that the file is still locked by the process.
Is there a way of opening the file for read and write access?
Code:
Expand|Select|Wrap|Line Numbers
- public static void editXML()
- {
- if (File.Exists("Locations.xml"))
- {
- Process process = new Process();
- ProcessStartInfo startinfo = new ProcessStartInfo("Notepad.exe", Environment.CurrentDirectory.ToString() + "\\Locations.xml");
- process.StartInfo = startinfo;
- process.Start();
- process.Close();
- }
Paul