none
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
                        client.Dispose();

    pianoboyCoder

    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.

    https://msdn.microsoft.com/en-us/library/esst63h0(v=vs.110).aspx

    Best Regards,

    Wendy


    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 MSDNFSF@microsoft.com.

    Friday, February 2, 2018 10:45 PM
    Moderator