Link to home
Start Free TrialLog in
Avatar of GarethABC
GarethABCFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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

Avatar of dj_alik
dj_alik

Try download data:
c.DownloadData
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)
            fs.Close()
        End Using

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of GarethABC
GarethABC
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GarethABC

ASKER

see above