• 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

        Try
            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

0
GarethABC
Asked:
GarethABC
  • 2
1 Solution
 
dj_alikCommented:
Try download data:
c.DownloadData
check the recevied bytes size.
and save to file
Compare results.



      
0
 
abhinaypCommented:
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)
            fs.Close()
        End Using

Open in new window

0
 
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
0
 
GarethABCAuthor Commented:
see above
0
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