Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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