Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. File Download - web service

File Download - web service

Scheduled Pinned Locked Moved Visual Basic
comhelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jrmcdona
    wrote on last edited by
    #1

    I am trying to build a web service that downloads a file to my local directory. I have the basics here but I just cannot get it to work, anybody know of any examples on this. Here is my code so far. Dim l_oWR As WebRequest Dim l_oWebResp As WebResponse Dim l_oBR As BinaryReader Dim l_oBW As BinaryWriter Dim l_oStream As Stream Dim bFile() As Byte Dim l_iCnt As Long Dim l_dtNow As DateTime = DateTime.Now Dim l_sDir As String = l_dtNow.ToString("MMddyyyy") Dim l_oDir As Directory Dim l_sFile As String Dim l_sCnnStr As String Try 'download file l_oWR = HttpWebRequest.Create("http://www.abc.com/abc.exe") l_oWebResp = l_oWR.GetResponse() l_oBR = New BinaryReader(l_oWebResp.GetResponseStream(), Encoding.ASCII) l_iCnt = l_oWebResp.ContentLength bFile = l_oBR.ReadBytes(CType(l_iCnt, Integer)) If Not System.IO.Directory.Exists("C:\ofac") Then System.IO.Directory.CreateDirectory("C:\ofac") End If l_oStream = New FileStream("C:\ofac\t11sdall.exe", FileMode.Create, FileAccess.Write) l_oBW = New BinaryWriter(l_oStream) l_oBW.Write(bFile) Thanks for any help here! Jordan

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups