- 
      
- 
        Save ashumeow/8bc0581d1bce3eabac98 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | [Fact] | |
| public void RemoveBom() | |
| { | |
| foreach (var file in new DirectoryInfo("..\\..").EnumerateFiles("*", SearchOption.AllDirectories)) | |
| { | |
| try | |
| { | |
| var allBytes = File.ReadAllBytes(file.FullName); | |
| var allText = File.ReadAllText(file.FullName); | |
| if (allBytes.Length - allText.Length == 3 && | |
| allBytes[0] == 0xef && | |
| allBytes[1] == 0xbb && | |
| allBytes[2] == 0xbf) | |
| { | |
| Console.WriteLine("{0} {1}", file.FullName, file.Length); | |
| File.WriteAllText(file.FullName, allText, Encoding.Default); | |
| } | |
| } | |
| catch | |
| { | |
| } | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment