How to download a file and save it

Discussion in 'Questions (Windows Mobile)' started by halo, Feb 13, 2009.

  1. halo

    halo Member Licensed User

    Hi
    Sorry about my broken english.
    The main reason why I bought Basic4PPC is,every day I want to download a file from the internet and save it on my HTC Touch Diamond.

    To get startet with basic4ppc I need your :sign0085:
    I think I have to use the HTTP library.

    For example I want to download this file:
    http://www.basic4ppc.com/files/SpriteExample.zip

    Could you please give me an example for downloading this file.

    Best regards
    Halo :sign0104:
     
  2. Mr_Gee

    Mr_Gee Active Member Licensed User

    Welcome to B4PPC and the forum...

    As for your request, have you seen the help files?
    if you look at this page (and scroll down a bit)
    you will see the download sub
    HTTP
     
  3. halo

    halo Member Licensed User

    Ok
    Thank you Mr_Gee
    With this code I can download the File:
    Code:
    Sub Globals
          
    Dim Buffer(0As byte
    End Sub

    Sub App_Start
          URL = 
    "http://www.basic4ppc.com/forum/images/Basic4ppc2.gif"
          DownloadFile(AppPath & 
    "\NewImage.gif",URL)
    End Sub

    Sub DownloadFile (LocalFile,URL)
          Response.New1
          Request.New1(URL)
          Response.Value = Request.GetResponse 
    'Launch the request and get the response.
          Msgbox("Download size: " & Response.ContentLength) 'Show the file size.
          Reader.New1(Response.GetStream,True'Use a BinaryFile object to read the data from the Response stream.
          FileOpen(c1,LocalFile,cRandom)
          Writer.New1(c1,
    False)
          
    Dim buffer(4096As byte
          count = Reader.ReadBytes(buffer(),
    4096)
          
    Do While count > 0
                Writer.WriteBytes2(buffer(),
    0,count)
                count = Reader.ReadBytes(buffer(),
    4096)
          
    Loop
          FileClose(c1)     
          Response.Close 
    'Close the Response stream.
          Msgbox("File saved.")
    End Sub
    I did not understand very much of this code, but it runs.
    I saw this example bevor. But I have very much problems with understanding wich object i have to add. Sorry for my dopyness.

    Thank you very much for your help.

    Greets Halo
     
  4. Mr_Gee

    Mr_Gee Active Member Licensed User

    yes thats the one..

    I understand it can be a bit overwhelming at first, but when you are working with the application for a while you will get accustomed to it...

    my advise start with the tutorials, the are really good
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice