Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8469009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:06:22+00:00 2026-06-10T16:06:22+00:00

I am uploading a file(Zip with the size 100MB) using WebClient but it works

  • 0


I am uploading a file(Zip with the size 100MB) using WebClient but it works fine some times, Fail some times

Here is My Code Please let me know your Views and What need to be done to Make it Consistent

public bool UploadFirmware(string srcPath, string destPath)
    {
        bool status = false;
        List<Unisys.sPar.FirmwareInfo> orgFwList = new List<Unisys.sPar.FirmwareInfo>();
        List<Unisys.sPar.FirmwareInfo> upFwList = new List<Unisys.sPar.FirmwareInfo>();
        try
        {
            orgFwList = EnumerateFirmware();
            Uri fwuri = new Uri(destPath);
            string myStringWebResource = null;
            WebClient myWebClient = new WebClient();
            myStringWebResource = fwuri.ToString();
            myWebClient.Encoding = Encoding.UTF8;
            myWebClient.Credentials = new NetworkCredential(userName, password);
            myWebClient.Headers[HttpRequestHeader.ContentType] = "application/zip";
            bool gExecuteOnce = true;
            ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications);
            myWebClient.UploadFileCompleted += new UploadFileCompletedEventHandler(myWebClientUploadloadFileCompleted);
            myWebClient.UploadFileAsync(new System.Uri(myStringWebResource), "POST", srcPath);//upload method 
            while (myWebClient.IsBusy)
            {
                System.Threading.Thread.Sleep(10000);
                if (gExecuteOnce == true)
                {
                    SPARTestToolInit.logger.Log(NLog.LogLevel.Info, "Please Wait Uploading firmware.....");
                    gExecuteOnce = false;
                }

            }
            upFwList = EnumerateFirmware();
            if (upFwList.Count == orgFwList.Count + 1)
            {
                status = true;
                SPARTestToolInit.logger.Log(NLog.LogLevel.Info, "Firmware Uploaded sucessfuly .....");
            }

        }
        catch (Exception ex)
        {
            status = false;
            SPARTestToolInit.logger.Log(NLog.LogLevel.Error, "Unable to upload firmware due to " + ex.ToString());
        }

        return status;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T16:06:23+00:00Added an answer on June 10, 2026 at 4:06 pm
         1. don't pool if webclient busy, you have a callback   myWebClientUploadloadFileCompleted
         2. set successfull status in you completed callback not in your method
    
         static ManualResetEvent done = new ManualResetEvent(false);
    
    
              public bool UploadFirmware(string srcPath, string destPath)
                    {
                        bool status = false;
                        List<Unisys.sPar.FirmwareInfo> orgFwList = new List<Unisys.sPar.FirmwareInfo>();
                        List<Unisys.sPar.FirmwareInfo> upFwList = new List<Unisys.sPar.FirmwareInfo>();
                        try
                        {
                            orgFwList = EnumerateFirmware();
                            Uri fwuri = new Uri(destPath);
                            string myStringWebResource = null;
                            WebClient myWebClient = new WebClient();
                            myStringWebResource = fwuri.ToString();
                            myWebClient.Encoding = Encoding.UTF8;
                            myWebClient.Credentials = new NetworkCredential(userName, password);
                            myWebClient.Headers[HttpRequestHeader.ContentType] = "application/zip";
                            bool gExecuteOnce = true;
                            ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications);
                            myWebClient.UploadFileCompleted += new UploadFileCompletedEventHandler(myWebClientUploadloadFileCompleted);
                            myWebClient.UploadFileAsync(new System.Uri(myStringWebResource), "POST", srcPath);//upload method 
    
                          done.WaitOne();//wait signal from completed callback
    
                        }
                        catch (Exception ex)
                        {
                            status = false;
                            SPARTestToolInit.logger.Log(NLog.LogLevel.Error, "Unable to upload firmware due to " + ex.ToString());
                        }
    
                        return status;
                    }
    
    
    static void client_UploadFileCompleted(object sender, UploadFileCompletedEventArgs e)
        {
            done.Set();
        }
    
    static void client_UploadProgressChanged(object sender, UploadProgressChangedEventArgs e)
        {
            //set your progress log
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

am I uploading this file right? Here is my code: Deleted Code it is
I'm uploading a zip file to Bugzilla with the following code: bug.AppendAttachment(someComment, application/octet-stream, somedata,
I am uploading a csv file and then parsing it using str_getcsv. All works
I am using shell command to zip file in ruby. Then I am uploading
Actually I'm creating an application for uploading file using JSF. But whenever I upload
I am uploading a file in my ASP.NET MVC application using Uploadify. Controller: public
I working on adding file uploading to my web application. I'm using an iframe
i'm uploading a 70mb ZIP file . perhaps debugging may be putting things out
Im uploading zip file (compressed with winrar) to my server by FileUpload control. On
UPDATE 1: Here is the full code behind from the downloaded example, unedited: using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.