Download file uploaded on web server to windows c# application RRS feed

  • Question

  • Hello,

    I have two applications web and desktop both shares same database. I uploaded jpg or png files from web application and try to check thru windows application , it downloads file with 0 size and won't display in win application.

    1. When i upload and check file from web application and check in web application its shows properly.

    2. When i upload and check file from windows application and check in win application its shows properly.

    But cross check won't work.

    Code wrote in windows application -

     Dim webClient As WebClient = New WebClient()

     webClient.DownloadFileAsync(URL, filePath)

    Catch ex As WebException
       End Try
    image = System.Drawing.Image.FromFile(filePath)

    Need urgent help.

    Thanks & Regards,

    Monday, March 2, 2020 4:23 PM

All replies

  • Hello,

    Perhaps credentials are needed.

    Private Sub DownLoadFile(urlAddress As String, filePath As String, userName As String, userPassword As String)
            Using client = New WebClient()
                client.Credentials = New NetworkCredential(userName, userPassword)
                client.DownloadFileAsync(New Uri(urlAddress), filePath)
                AddHandler client.DownloadFileCompleted, AddressOf Completed
            End Using
        Catch ex As Exception
        End Try
    End Sub
    Private Sub Completed(sender As Object, e As AsyncCompletedEventArgs)
    End Sub

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    profile for Karen Payne on Stack Exchange

    Monday, March 2, 2020 8:04 PM
  • Hi nupurd,

    How is the question going? Please let me know if you need further assistance.

    Best Regards,

    Xingyu Zhao

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Wednesday, March 11, 2020 5:42 AM