Sub UploadData() As Boolean
If File.Exists(File.DirDefaultExternal,"Data.txt") Then
Dim sReader As TextReader,sRecord As String
Dim IPReader As TextReader,IPWriter As TextWriter
Dim IntGood As Int, intBad As Int
Dim fTotal As Long,fProcessed As Long
fTotal=File.Size(File.DirDefaultExternal,"Data.txt")
IPReader.Initialize(IP.InputStream)
IPWriter.Initialize(IP.OutputStream)
ProgressBar1.Progress=0
sReader.Initialize(File.OpenInput(File.DirDefaultExternal,"Data.txt"))
Do While sReader.Ready
sRecord=sReader.readline
If sRecord.Length>1 Then
fProcessed=fProcessed+sRecord.Length
ProgressBar1.Progress=Round(fProcessed/fTotal*100)
IPWriter.WriteLine(sRecord)
IPWriter.Flush
sRecord=IPReader.readline
If sRecord.StartsWith("OK") Then
IntGood=IntGood+1 ' Executes this line then jumps to IP.Close
Else
intBad=intBad+1
End If
Else
Exit
End If
Loop
sReader.close
End If
IP.close ' Jumps here after the OK response??
Return True
End Sub