C#: How to make a log file?

Status
Not open for further replies.

kytro360

Member
Original poster
member
Joined
Sep 9, 2009
Posts
376
Reaction score
6
Points
75
I see several porgrams that basically tell the user what the bot is performing at the time. How do I make one?
 

Hax

Old School
old school
member
Joined
Aug 7, 2010
Posts
269
Reaction score
77
Points
143
Do you mean a text file that's external to the program, or a feature within the program that lists the bot's status?
 

Flip

Old School
old school
member
Joined
Jul 23, 2009
Posts
263
Reaction score
69
Points
108
Just make a textBox / richTextBox and change the text during certain actions of the program

ex:
Code:
webBrowser1.Navigate("http://google.com");
textBox.Text = "Navigating";
 
K

KamaluNg

Guest
You could make a listbox. then each time a new action happens you add the status text to your listbox then on closing it saves automatically.
 

Darkness

Veteran
veteran
old school
senior
Life Saver
coldschool
member
Joined
Jul 17, 2009
Posts
3,361
Reaction score
2,442
Points
180
Location
Toronto, Canada
Just make a textBox / richTextBox and change the text during certain actions of the program

ex:
Code:
webBrowser1.Navigate("http://google.com");
textBox.Text = "Navigating";

It'd be easier to use a ToolStripStatusLabel for that.

You could make a listbox. then each time a new action happens you add the status text to your listbox then on closing it saves automatically.
This is how I'd do it if I wasn't using a label.
 
  • Like
Reactions: kytro360

kytro360

Member
Original poster
member
Joined
Sep 9, 2009
Posts
376
Reaction score
6
Points
75
How would I code it for the ToolStripStatusLabel?
 

Darkness

Veteran
veteran
old school
senior
Life Saver
coldschool
member
Joined
Jul 17, 2009
Posts
3,361
Reaction score
2,442
Points
180
Location
Toronto, Canada
Drag a toolstrip onto your form. click on the + button or w/e. Click label. Then, whenever you are doing something you can do:
Code:
webBrowser1.Navigate("http://google.com");
toolstripStatusLabel1.Text = "Navigating";

This looks a lot nicer.
 
  • Like
Reactions: kytro360

Chaddith

Member
member
Joined
Jul 31, 2011
Posts
17
Reaction score
2
Points
0
You can use various methods to do this. You can use a rich textbox with different colors of text to indicate what type of function the program is performing. You can save everything to a .txt or .html or .log file that your program reads to keep logs.

Or my favorite one, just a simple textbox that tells you the history with a statusbar on the bottom and an enum function with a switch to make everything 100x easier.
 
Status
Not open for further replies.