Hi all,
I have a string like
string mess="Success";
I want to change color of "Success" to green and write it to a log file.
I am able to write the normal text (that is in black color) in a file. But I am not able to convert the text color.
Could some body please help with the peice of code.
Thanks
Murali krishna.
Loading
Murali krishna AndePosted Nov 16, 2010, 4:44 AM
Blocked AccountPosted Nov 16, 2010, 3:59 AM
You are writing in Logfile.txt as i think text file doesn't support color formatting.
thatswhy i suggested you that reference, in that he is trying to create rtf(rich text formatted) log file.
Thanks
Murali krishna AndePosted Nov 16, 2010, 2:58 AM
Thanks for the reply.
This is my code:
LogMessage("Uploaded the file","Success");
Private Void LogMessage(string Message,string SuccessorFailure)
{
StreamWriter sw;
string LogFormat = DateTime.Now.ToLongDateString().ToString() + " " + DateTime.Now.ToLongTimeString().ToString() + " " + " ==> ";
filePath = Path.Combine(filePath, "LogFile.txt");
if (File.Exists(filePath))
{
sw = File.AppendText(filePath);
}
else
{
sw = File.CreateText(filePath);
}
sw.WriteLine(LogFormat + " " + SuccessOrFailure + " " + Message);
sw.WriteLine("---------------------------------------------------");
sw.Close();
}
By using above function I wrote a message to log file.
What I want is, If it is success-- I want to dispaly it in green color, if it is failure--Red.
LogMessage("Uploaded the file","Success");
I want to convert the color of Text 'Success' to green.
Thanks
Murali krishna
Blocked AccountPosted Nov 16, 2010, 2:21 AM
Take the reference of this article.
http://www.gamedev.net/reference/programming/features/rtflog/