Learn how to a build a cloud-first strategyRegister Now


downloading file using WebClient

Posted on 2011-05-10
Medium Priority
Last Modified: 2012-05-11
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

Question by:GarethABC
  • 2
LVL 18

Expert Comment

ID: 35729757
Try download data:
check the recevied bytes size.
and save to file
Compare results.


Expert Comment

ID: 35730198
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


Accepted Solution

GarethABC earned 0 total points
ID: 35980880
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

Author Closing Comment

ID: 37271824
see above

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month20 days, 16 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question