The webclient Uploadfile Methods Hangs RRS feed

  • Question

  • The webclient Uploadfile method randomly Hangs. Can someone give me some assistance on the why the webclient UploadFile() function hangs. 

      WebClient client = new WebClient();
                        client.Credentials = CredentialCache.DefaultCredentials;
      client.UploadFile(ipaddr, "POST", @"C:\Temp\ImageShow\White--Dot.png" ); //It hangs on this line randomly


    Thursday, February 1, 2018 6:16 PM

All replies

  • Hi pianoboyCoder,

    Thank you for posting here.

    For your question, the way you used to upload file is right. What does the randomly Hangs mean? Does the code succeed before?

    What is your ipaddr, the method you used to send the file to the resource? You could set null, the default is POST for http and STOR for ftp.

    For more details, you could refer to the MSDN article.

    Best Regards,


    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

    Friday, February 2, 2018 10:45 PM