downloading file using WebClient

Posted on 2011-05-10
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
    LVL 18

    Expert Comment

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

    LVL 4

    Expert Comment

    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

    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

    see above

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    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…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now