Step 1: Download a database containing a list of files on a server
Step 2: (Only when step 1 complete) Open that database.
Step 3: Download the files listed in that database
How? In the example below I am only get the .db and the last file in the list of files. What an I doing wrong?
Step 2: (Only when step 1 complete) Open that database.
Step 3: Download the files listed in that database
How? In the example below I am only get the .db and the last file in the list of files. What an I doing wrong?
B4X:
Sub UpdateFiles
Dim Job1 As HTTPjob
Dim URL Prefix As String = "http://www.anysite.com/files/"
Job1.Initialize("FileList",Me)
Job1.Download(URLprefix & "MyDatabase.db")
End Sub
Sub JobDone (Job As HttpJob)
If Job.Success = True Then
Select Job.JobName
Case "FileList" 'Handle the database then open it
Dim out As OutputStream = File.OpenOutput(File.DirLibrary,"MyDatabase.db", False)
File.Copy2(Job.GetInputStream, out)
out.Close
Main.SQL1.Initialize(File.DirLibrary,"MyDatabase.db",False) 'Re-initialize the database
Dim Files As ResultSet = Main.SQL1.ExecQuery("SELECT * FROM FileList ORDER BY File")
Dim fname as string
Do While Files.NextRow 'Initiate the remaining downloads
fname = Files.GetString("File")
Job1.Initialize(fname,Me)
Job1.Download(URLprefix & fname)
Loop
Case Else 'Save the files listed in the database when they arrive
Dim out As OutputStream = File.OpenOutput(File.DirLibrary,Job.JobName, False)
File.Copy2(Job.GetInputStream, out)
out.Close
End Select
Else
Progress("Error: " & Job.ErrorMessage)
End If
End Sub