Skip to content

Instantly share code, notes, and snippets.

@kenegozi
Created September 16, 2010 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenegozi/582193 to your computer and use it in GitHub Desktop.
Save kenegozi/582193 to your computer and use it in GitHub Desktop.
fixing text files to DOS style line endings (CRLF)
c:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe fix_crlf.cs
fix_crlf.exe
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace FixCrLF
{
class Program
{
static void Main(string[] args)
{
var extensions = new[] {".aspx", ".cs", ".boo", ".css", ".js", ".txt"};
var root = Environment.CurrentDirectory;
var files = from f in Directory.EnumerateFiles(root, "*.*", SearchOption.AllDirectories)
let ext = Path.GetExtension(f)
where ext != null && extensions.Contains(ext)
select f;
foreach (var file in files)
{
Console.Write(file + " ... ");
var originalContent = File.ReadAllLines(file);
File.WriteAllLines(file, originalContent);
Console.WriteLine("done");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment