Sunday 15 January 2012

c# - Load a xml file using XDocument.Load from FileSystemWatcher. Error "The process cannot access the file..etc" -


What is the method of "file access to ATC can not process" error? The flow is that when I locate an XML file, the file systemwaters will look for an XML file, I need to read the specific node from the XML file.

How can I fix this? Thanksgiving

Here is the file system code

  Private Zero FilesSystemWriter Code (Object Sender, System.IO.FileSystemEventArgs e) {try {string type = GetType (e.FullPath) toupper (); If (type == "cc") {if (Global.pc_flag) {ProcessPC (e.FullPath); } And if (Global .mw_flag) {ProcessMW (e.FullPath); } And {process XML (E. fullpath); }} And if (type == "gc") {ProcessMW (e.FullPath); } // Processes (E. Fulpath); } Hold (exception before) {error ++; LblErrors.Text = error.ToString (); MessageBox.Show (ex.Message); }}   

Here's what GetType is included

  Private string GetType (string file) {string type = string.Empty; (Var Stream = File. Open (File, FileMod. Open, File Access. Read, Fizaire Reddit)) {var request = XDocument.Load (stream); Var get_command = request.Descendants ("Transactions") New {type = R. Select Element ("Type"). Values}; Leading (var c in get_command) {type = c.Type; }} Return type; }    

You do not use your stream in the code And when the stream is open, you can not see the file in the XDocument.Load (file)

  private string GetType (string file) {string type = string .Empty; Var request = XDocument.Load (file); Var get_command = request.Descendants ("Transactions") New {type = R. Select Element ("Type"). Values}; Leading (var c in get_command) {type = c.Type; } Return type; }    

No comments:

Post a Comment