How to read a text file into a textbox in C #

How to read live text from a text file into a text field in C #? The file is constantly being updated by another process and we need to keep displaying the updated text in the text box.

Any hint would be appreciated,

Thanks,

+2


a source to share


3 answers


You should probably consider using a FileSystemWatcher to track changes to the file and update the contents of the text box whenever you detect a change. However, you need to be careful about concurrency and file locking. Probably the safest way to do this is to read the file into a separate string object, and only update the text field if you are happy that the read operation was successful.



+3


a source


FileSystemWatcher

class can help you with this:

FileSystemWatcher Class (MSDN)



Cheers Matthias

0


a source


Use FileSystemWatcher and catch the Onchanged event. And process it by reading the file again!

0


a source







All Articles