private Sub UploadAllUserAccounts(SendFileInfo As Boolean,StreamSource As AsyncStreams) As Boolean
Dim Size As ULong = 0
SetSD(ON)
LCD.Clear
PutString(0,1,"Please Wait...",True)
If SendFileInfo Then
For Each Fl As File In SD.ListFiles("dat") ' get total file size in folder
Size = Size + 66 + 2 'only first four fields
Next
'send file info only for once, upload user files as stream of ONE united file
Dim Tmp(18) As Byte
Dim RAF As RandomAccessFile
RAF.Initialize(Tmp,False)
RAF.WriteByte(0x02,RAF.CurrentPosition)
RAF.WriteBytes("USERS.DB".GetBytes,0,8,RAF.CurrentPosition)
RAF.WriteByte(SYS_DATA_FILES_DELIMITION_CHR,RAF.CurrentPosition)
RAF.WriteBytes(NumberFormat(Size,8,0).GetBytes,0,8,RAF.CurrentPosition) 'file size
SetSD(OFF)
SendStreamMessage(Tmp,Tmp.Length,True,StreamSource)
SetSD(ON)
End If
'Dim cb(101) As Byte
Dim cb(66) As Byte
For Each f As File In SD.ListFiles("dat")
If SD.OpenRead(GetUserAccountFileName(f.Name)) = False Then
LCD.Clear
Return False
End If
'SD.Stream.ReadBytes(cb,0,101) 'read 101 bytes
SD.Stream.ReadBytes(cb,0,66)
SD.Stream.Flush
Delay(10)
SD.close
SetSD (OFF)
SendStreamMessage(cb,cb.Length,True,StreamSource)
SetSD (ON)
Next
LCD.Clear
SetSD (OFF)
SendStreamMessage(Array As Byte (0x04),1,True,StreamSource)'end of transmission
'SetSD (True)
Return True
End Sub