How to Download files once until the file is correctly downloaded

I have a program that I made that download files from a table.

For this I use:

  1. A Cookie
  2. An HTTPSecureSocket

So I do this:

  if downloadSocket.Get(enlace, SAVEFILETEMP, 19) = True then  //
    SolucionFinal(SAVEFILETEMP,ConteoTotal,f,Mes,Year,FileName,ValidStatus)
    
End If

As you can see, I told that If the file is successfully downloaded, then, proceed to execute the next method.

So, whats the problem. Example:
Is I have 900 files to download. It only downloads 600 or 700 files

So then I do this:

  if downloadSocket.Get(enlace, SAVEFILETEMP, 19) = True then  //Primero deberiamos analizarlo y despues guardarlo a SAVEFILE
    SolucionFinal(SAVEFILETEMP,ConteoTotal,f,Mes,Year,FileName,ValidStatus)
    
  Else
    
    if downloadSocket.Get(enlace, SAVEFILETEMP, 19) = True then
      SolucionFinal(SAVEFILETEMP,ConteoTotal,f,Mes,Year,FileName,ValidStatus) //Provisional
      
    Else
      if downloadSocket.Get(enlace, SAVEFILETEMP, 19) = True then
        SolucionFinal(SAVEFILETEMP,ConteoTotal,f,Mes,Year,FileName,ValidStatus) //Provisional
      Else
        
        if downloadSocket.Get(enlace, SAVEFILETEMP, 19) = True then
          SolucionFinal(SAVEFILETEMP,ConteoTotal,f,Mes,Year,FileName,ValidStatus) //Provisional
        End If
        
      End If
      
      
    End If
    
    NumErrors = NumErrors + 1

    
  end if
  

Doing this an If Inside another IF and then another inside of it, in case “ELSE”, In case that the file not no be downloaded, so Download it again.

If I of that, example If I downloaded 600 files, now I can download 800 or 850 files, But not the 900 files.

So my question is, Is there a way do do it an infinite times until the files are correctly downloaded?

Thanks

[quote=303023:@Gerardo García]I have a program that I made that download files from a table.

For this I use:

  1. A Cookie
  2. An HTTPSecureSocket

So I do this:

  if downloadSocket.Get(enlace, SAVEFILETEMP, 19) = True then  //
    SolucionFinal(SAVEFILETEMP,ConteoTotal,f,Mes,Year,FileName,ValidStatus)
    
End If

As you can see, I told that If the file is successfully downloaded, then, proceed to execute the next method.

So, whats the problem. Example:
Is I have 900 files to download. It only downloads 600 or 700 files

So then I do this:

  if downloadSocket.Get(enlace, SAVEFILETEMP, 19) = True then  //Primero deberiamos analizarlo y despues guardarlo a SAVEFILE
    SolucionFinal(SAVEFILETEMP,ConteoTotal,f,Mes,Year,FileName,ValidStatus)
    
  Else
    
    if downloadSocket.Get(enlace, SAVEFILETEMP, 19) = True then
      SolucionFinal(SAVEFILETEMP,ConteoTotal,f,Mes,Year,FileName,ValidStatus) //Provisional
      
    Else
      if downloadSocket.Get(enlace, SAVEFILETEMP, 19) = True then
        SolucionFinal(SAVEFILETEMP,ConteoTotal,f,Mes,Year,FileName,ValidStatus) //Provisional
      Else
        
        if downloadSocket.Get(enlace, SAVEFILETEMP, 19) = True then
          SolucionFinal(SAVEFILETEMP,ConteoTotal,f,Mes,Year,FileName,ValidStatus) //Provisional
        End If
        
      End If
      
      
    End If
    
    NumErrors = NumErrors + 1

    
  end if
  

Doing this an If Inside another IF and then another inside of it, in case “ELSE”, In case that the file not no be downloaded, so Download it again.

If I of that, example If I downloaded 600 files, now I can download 800 or 850 files, But not the 900 files.

So my question is, Is there a way do do it an infinite times until the files are correctly downloaded?

Thanks[/quote]

I also tried to change the timeout without success

You might have more success if you build a queue and subclass HTTPSocket to run asynchronous requests instead.