Reputation: 205
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,
Upvotes: 2
Views: 1972
Reputation: 29953
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.
Upvotes: 3
Reputation: 21880
Use a FileSystemWatcher and catch the event Onchanged. And handle it by reading the file again!
Upvotes: 0
Reputation: 12513
FileSystemWatcher
class might help you doing this:
FileSystemWatcher Class (MSDN)
Cheers Matthias
Upvotes: 0