Text File Refresh

CarcaBot

Well-known member
Joined
Apr 23, 2007
Messages
47
Location
Romania
Programming Experience
Beginner
Hy all,
i wanna refresh a text file on each 5 seconds for example.
how i can ?

and how i can set at startup a application ?

thx in advance.
 
i would use a timer control for this, setting it's interval to 5000 (5 seconds) and in the form load event (or sub main if that's how the app is starting) simply start the timer

also be sure to stop the timer in the form's closing event
 
i don't know how to refresh file reading on each x seconds...
i need it for a news ticker, i saved the file in my.settings
and i don't know how to refresh it
 
for text files there is the System.IO.StreamReader to read text files and System.IO.StreamWriter to make and append to text files
 
yea but Refresh or reload is not a member of system.io.streamreader

// later edit

i saw you msdn forum where the topic was "auto reload file" this answer
" Unfortunately, there is no way to suppress this message in VS 2005. If you think that this would be a good addition please file a suggestion in our MSDN Product Feedback Center. (http://lab.msdn.microsoft.com/productfeedback/default.aspx) "

maybe have right !?
 
Last edited:
I dont know what you mean by refresh...

To me it could either mean you want to write completely to the file every 5 seconds replacing its content
Or you could want to look at it every 5 seconds reloading the contents

Either way, you just repeat whatever you did the first time, 5 seconds later

Please be more specific when asking your question
 
How about you add Timer to Form, set Interval to 5000 milliseconds and Enabled to True, doubleclick it to get to the Tick event and there you write the code you want to happen each interval.
 
It does too.
 
VB.NET:
 Dim sr As New IO.StreamReader(My.Settings.file1)
        Dim arr() As String = Regex.Split(sr.ReadToEnd(), "\r\n")
        sr.Close()
        For Each s As String In arr
           str += " * " & s 
        Next
 
ok, I see that you're opening the file and reading all the contents of the file to an array while using a RegularExpression to do something, which is also splitting the contents of the file based on the pattern

What's the regex pattern? also what's with the {str += " * " & s} line?
 
Back
Top