Вы также можете использовать дословную среду
\begin{verbatim}
your
code
example
\end{verbatim}
This code from codeproject may be a good starting point.
Eraser has been around for years, you could call out to it by using System.Diagnostics.Process, or at least review the algorithm there.