Hi,
I'm trying to add the numbers in a text file and show the result on a label.
Public Function GetInitialTime(ByVal TotalTime As Integer) As String
Dim fileContents() As String = IO.File.ReadAllLines("\My Documents\my_Counter.txt")
Dim sum As Long = (From item In fileContents Select CLng(item)).Sum
TotalTime = sum
Tot_Time = TotalTime
Sec = TotalTime Mod 60
Min = ((TotalTime - Sec) / 60) Mod 60
Hrs = ((TotalTime - (Sec + (Min * 60))) / 3600)
Return Format(Hrs, "000000") & ":" & Format(Min, "00") & ":" & Format(Sec, "00")
End Function
For the mobile phone (win6.5) development it comes with an error:
"ReadAllLines" is not a member of "System.IO.File"
But if I create a development for a PC application and use the same code, it works fine.
Can anybody help me?
Or has anybody got another idea of how to add all lines (there are only numbers on each line) in my text file?
Thanks.
I'm trying to add the numbers in a text file and show the result on a label.
Quote:
Public Function GetInitialTime(ByVal TotalTime As Integer) As String
Dim fileContents() As String = IO.File.ReadAllLines("\My Documents\my_Counter.txt")
Dim sum As Long = (From item In fileContents Select CLng(item)).Sum
TotalTime = sum
Tot_Time = TotalTime
Sec = TotalTime Mod 60
Min = ((TotalTime - Sec) / 60) Mod 60
Hrs = ((TotalTime - (Sec + (Min * 60))) / 3600)
Return Format(Hrs, "000000") & ":" & Format(Min, "00") & ":" & Format(Sec, "00")
End Function
Quote:
"ReadAllLines" is not a member of "System.IO.File"
Can anybody help me?
Or has anybody got another idea of how to add all lines (there are only numbers on each line) in my text file?
Thanks.