I’m trying to read specific values from the text file (below):
Current Online Users: 0
Total User Logins: 0
Server Uptime: 0 day, 0 hour, 0 minute
Downloaded Amount: 0.000 KB
Uploaded Amount: 0.000 MB
Downloaded Files: 0
Uploaded Files: 0
Download Bandwidth Utilization: 0.00 KB/s
Upload Bandwidth Utilization: 000.00 KB/s
I can read the file to an array:
Dim path As String = "C:\Stats.txt"
Dim StringArrayOfTextLines() As String = System.IO.File.ReadAllLines(path)
How do I store only the data I require in the array? I’ve tried split and substring but cannot work out a usable method – I need on the text after the colon for each line.
I was thinking, I only require the numerical data, can this be extracted from each line rather than just splitting into an array?
Thanks.
To capture everything after the colon you just need to split on it and take the second element of each result:
If you want to do that as you read the data you’ll need to use a
StreamReaderlike Joel suggested.