title: Remove Non-ASCII characters from XML file C#
body: <p>I am trying to write a program to remove open an XML file with Non-ASCII characters and replace those characters with spaces and save and close the file.</p>
  
  <p>Thats basically it, just open the file remove all the non ascii characters and save/close the file.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Xml;
  using System.IO;
  using System.Text.RegularExpressions;
  
  namespace RemoveSpecial
  {
      class Program
      {
          static void Main(string[] args)
          {
              string pth_input = string.Empty;
              string pth_output = string.Empty;
              for (int i = 1; i &lt; args.Length; i++)
              {
                  //input one
                  string p_input = args[0];
                  pth_input = p_input;
                  pth_input = pth_input.Replace(@"\", @"\\");
  
  
                  //output
                  string p_output = args[2];
                  pth_output = p_output;
                  pth_output = pth_output.Replace(@"\", @"\\");
              }
  
              //s = Regex.Replace(s, @"[^\u0000-\u007F]+", string.Empty);
  
  
  
              string lx;
  
              using (StreamReader sr = new StreamReader(pth_input))
              {
                  using (StreamWriter x = new StreamWriter(pth_output))
                  {
                      while ((lx = sr.ReadLine()) != null)
                      {
                          string text = sr.ReadToEnd();
  
                          Regex.Replace(text, @"[^\u0000-\u007F]+", "", RegexOptions.Compiled);
                          x.Write(text);
                      } sr.Close();
  
                  }
              }
  
  
          }
  
  
      }
  }
  </code></pre>
  
  <p>Thanks in advance guys.</p>