A while ago, I was searching through IIS DLL's
looking for a specific error message. Like most things, there's my way and the easy way.
My way: a tiny SnippetCompiler special that creates a notepad friendly
copy of any binary file. Posting the code in case it saves someone some time on
a similar task.
public class StripNonAscii
public static void Main()
Console.WriteLine("This strips non-ASCII characters from a binary file so you can search for text strings.");
Console.WriteLine("Enter the full path and filename to convert:");
string sourceFile = Console.ReadLine();
FileStream fs = new FileStream(sourceFile, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
FileStream fsOut = new FileStream(sourceFile + ".txt", FileMode.CreateNew);
BinaryWriter w = new BinaryWriter(fsOut);
// Read data from Test.data.
for (int i = 0; i < r.BaseStream.Length; i++)
byte val = r.ReadByte();
if(val==10 || val ==13 || (val>31 && val<127))
Console.WriteLine("File written to: " + sourceFile + ".txt");
Console.WriteLine("Enter the full path and filename to convert, or ENTER to exit:");
sourceFile = Console.ReadLine();
The right way was probably to use strings.exe from Sysinternals, which can rip through a whole folder
detecting string (ANSI and Unicode) of a minimum character length.
powered by IMHO 1.2