How to read live text from a text file into textbox in C#? The file is being updated all the time by another process, and we need to keep displaying the updated text in the textbox.
Any hint will be appreciated,
Thanks,
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You should probably think about using a FileSystemWatcher to track changes to the file, and refresh the contents of the textbox whenever you detect a change. You’ll need to be careful about concurrency and file locking, though. Probably the safest way to do it would be to read the file into a separate string object, and only update the textbox once you are happy that the read operation succeeded.