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
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) "
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
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.
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?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.