Click here to Skip to main content
15,911,306 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi..

I am trying to read compilation errors into a text file...how to read the compiler errors into a text file... anybody can help
Posted
Comments
Sergey Alexandrovich Kryukov 19-Feb-14 12:05pm    
This is quite possible. But — of what compiler, compiling what? What scenario are you interested in? The answers would be very different.
—SA

1 solution

You can do it with C++, but you can't do it with C# apparently: http://msdn.microsoft.com/en-us/library/jj651643.aspx[^]

"After you build a project in the Visual Studio IDE, you can view information about that build in the Output window. By using this information, you can, for example, troubleshoot a build failure. For C++ projects, you can also view the same information in a .txt file that's created and saved automatically. For managed-code projects, you can copy and paste the information from the Output window into a .txt file and save it yourself."
 
Share this answer
 
Comments
Divyay208 19-Feb-14 8:05am    
thank you for your response... will you please explain me how to copy that output window error message into a text file...i just want to show the error message in catch block txt file
OriginalGriff 19-Feb-14 8:13am    
A catch block error is different: that isn't a compilation error, that's a runtime error.
But in VS that is just trivially easy!
Click in the output pane, and press CTRL+S
That will bring up a dialog letting you save the entire output pane to a text file.
Divyay208 20-Feb-14 1:52am    
k can u please give some suggestion that am writing C# .net code in my own editor and now i want to compile that code before saving it into a .cs file
OriginalGriff 20-Feb-14 4:32am    
Ah! That's different - you should have said!

To compile it is pretty easy: CSC will do that (and a quick google will get you the parameters you need). Output is slightly more complex, but not a lot.
The simplest way to do it is to pipe the output to a text file:
csc program.cs >> err.txt
And that will work from a command prompt, and should work from Process.Start.
But...if you are using Process.Start to compile, there may be a better way. Have you looked at Process and it's properties at all?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900