• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 326
  • Last Modified:

downloading file using WebClient

Hi all

I am trying to download a file from a website and saving it to our server.

All works ok using the following code but the file is back to front compared to the original, ie page 10 is page 1 and vice versa

Any ideas why? The file is a tif file if that helps

Thanks in advance

Protected Function createFile(ByVal url As String, ByVal saveFilePath As String) As Boolean

            Dim c As New WebClient()
            c.DownloadFile(url, saveFilePath)
            Return True

        Catch ex As Exception
            Return False
        End Try

    End Function

Open in new window

  • 2
1 Solution
Try download data:
check the recevied bytes size.
and save to file
Compare results.

Try using byte, fliestream..
Dim wc As New Net.WebClient()
        wc.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials
        Dim buff As Byte() = wc.DownloadData(fileUrl)
        Using fs As System.IO.FileStream = New FileStream("C:\test\img.tif", FileMode.Create)
            fs.Write(buff, 0, buff.Length)
        End Using

Open in new window

GarethABCAuthor Commented:
Thanks for the answers, it was actually a problem with the company that supplied the software in the first place that was creating the pdf.

Thanks again
GarethABCAuthor Commented:
see above
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now