Tutorial :Best Method for Printing .NET Source Code [closed]


I have an old skool professor that requires that we print out all of our project source code for him to review. I am writing this app in VS 2008 and the solution contains a C# Web App and several Class Libraries (consisting of probably 100 files total).

Anyone have experience with a good method of printing out many source files like this? I'm doubting that you can take a solution into Kinkos...


Write a macros in VS.


I tested these 2 batch files on my XP system against my project folder and it worked.

Batch file 1 - update to point to correct path - run this file after saving both batch files. I would save this one as doit.bat:

for /f "tokens=*" %%a IN ('dir /b /s "c:\temp\myrootcodefolder\*.*"') do call allmycode.bat %%a %%~xa  

Batch file 2 - Update to include any extensions you need that I didn't list. Be sure to save as allmycode.bat

if %2.==. goto :END    if %2==.vb goto :OUTPUT  if %2==.cs goto :OUTPUT  if %2==.aspx goto :OUTPUT  if %2==.txt goto :OUTPUT  if %2==.config goto :OUTPUT  if %2==.asax goto :OUTPUT  if %2==.asmx goto :OUTPUT  if %2==.skin goto :OUTPUT    GOTO :END    :OUTPUT  echo. >> allmycode.txt  echo. >> allmycode.txt  echo ============================================ %1 >> allmycode.txt  echo. >> allmycode.txt  type %1 >> allmycode.txt    :END  


I would write a quick script to append all of the source files together into one text file. Include 'breaks' that include file paths and names to delimit different source files. Then, just print the resulting file.

This method would cut down on time/paper waste.


You could try using a VS plugin.

Some answers here: What is the best Visual Studio Plugin for Printing Code


Possibly more work than you're willing to put into this, but LaTeX together with the Listings package will provide you with paging, advanced formatting, line numbers etc. Including source code files is then a matter of adding such statements as:

\lstinputlisting{class1.cs}  \lstinputlisting{class2.cs}  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »