-3

I am creating a Windows Form application.

I created a log file which is saved in the following path: "Application/bin/debux/log.txt".

  1. How can I read this file from the bin folder in a RichTextBox?
  2. When I published this application, I saw the folder "Application Files" after installation. Is it possible to put my log.txt there?
Nahuel Ianni
  • 3,177
  • 4
  • 23
  • 30
Eryk
  • 5
  • 1
  • 1
    1. Read the file and set the content of your control to it. 2. You can put it anywhere you want unless you lack privilegies to access the folder from code. – Nahuel Ianni Aug 29 '14 at 10:36
  • Have you searched for resources on how to read a text file in c#? This is a common task are there are many resources online that would help you. Are you facing a specific problem? – Daniel Kelley Aug 29 '14 at 10:37

2 Answers2

0

If I were you I would use http://logging.apache.org/log4net/ (Apache log4net) for logging and write a custom appender in order to write into the RichTextBox. You even can copy & paste the code from RichTextBoxAppender using log4net.

Community
  • 1
  • 1
Tony Stark
  • 2,318
  • 1
  • 22
  • 41
-1

try this

RIRichTextBox.Text = System.IO.File.ReadAllText(Environment.CurrentDirectory+"log.txt");
sms247
  • 4,404
  • 5
  • 35
  • 45