|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Auto Update text when txt file changes
I have a form that has a richtxtbox that displays text from a .txt file.
Is there a way to have the box automatically change if the text file changes, without reloading the form? Thanks in advance. |
|
#2
|
|||
|
|||
|
I don't know any way to do this, but I do only real basic file system stuff. Maybe there is a "file changed" event somewhere in the windows API or something.
|
|
#3
|
||||
|
||||
|
create a project reference to the Microsoft scripting runtime library. Create a new variable of type FileSystemObject, and you can use it like so
Code:
Dim fso As New FileSystemObject dim DateLast as datetime DateLast = fso.GetFile.DateLastModified Do this in two places, once on form load, and hold that value in a global value, and again in a timed event to fire every once in a while. If the two dates do not match, then someone has changed and saved the file, and you can ask the user if they would like to reload the saved file. If they click yes (on a messagebox), then you have a procedure that clears your rtf box and reloads it with the current contents.
__________________
Fisherman "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein |
|
#4
|
||||
|
||||
|
I guess I should say that you will have to tell you fso where the file you are using is located, but I'm sure you can figure that one out.
|
|
#5
|
|||
|
|||
|
Buddy, the recommended way to be informed when a file (or directory) changes is to use the FindFirstChangeNotification API call (and its associated calls). Look at this url and expecially the example link it supplies:
http://www.mentalis.org/apilist/Fin...ification.shtml |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Auto Update text when txt file changes |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|