divyeshog

xml file opening error

Aug 23rd, 2017
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.03 KB | None | 0 0
  1. string[] Filelist = Directory.GetFiles(this.XML_FPath_Textbox.Text.ToString());
  2.             try
  3.             {
  4.                 foreach (string file in Filelist)
  5.                 {
  6.                     Application.DoEvents();
  7.                     XmlDocument xmldoc = new XmlDocument();
  8.                     XmlNodeList xmlnode;
  9.                     FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read);
  10.                     xmldoc.Load(fs);
  11.                     xmlnode = xmldoc.GetElementsByTagName("Source");
  12.                     foreach (XmlNode n in xmlnode)
  13.                     {
  14.                        string token = n.InnerText.ToString().Replace(@"\\az77-fs1\epic_rel\", "");
  15.                        string Destination_File_Name = Path.GetFileName(token);
  16.                        string[] tokenaizer = token.ToString().Split('\\');
  17.                        if (Regex.IsMatch(token, "names.dat", RegexOptions.IgnoreCase))
  18.                        {
  19.                            using (StreamWriter sw = new StreamWriter("Analyzer.txt",true))
  20.                            {
  21.                                token = Regex.Replace(token, @"THIRD_PARTY\\", "", RegexOptions.IgnoreCase);
  22.                                token = Regex.Replace(token,@"platforms\\","",RegexOptions.IgnoreCase);
  23.                                token = Regex.Replace(token,@"productsoftware\\","",RegexOptions.IgnoreCase);
  24.                                sw.WriteLine(token.ToString());
  25.                            }
  26.                        }
  27.                     }
  28.                 }
  29.  
  30.                 string[] lines = File.ReadAllLines(@"Analyzer.txt");
  31.                 lines = lines.GroupBy(x => x).Where(g => g.Count() > 1).Select(g => g.Key).ToArray();
  32.                 File.WriteAllLines(@"AnalyzerFINAL.txt", lines);
  33.                 Process.Start("notepad.exe", "AnalyzerFINAL.txt");
  34.             }
  35.             catch (Exception ex)
  36.             {
  37.                 MessageBox.Show(ex.Message.ToString(), "Analyzer", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  38.             }
Add Comment
Please, Sign In to add comment