Click here to Skip to main content
15,921,841 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a windows form for autouploading all excel files in a folder. It has two buttons start and stop and a timer. When the start button is clicked the process starts. The problem is that it takes nearly half an hour to upload a single file.The process is too slow .Each excel files has 500-600 rows. Can someone help me please.

What I have tried:

 private void strtbtn_Click(object sender, EventArgs e)
         {
             timer1.Enabled = true;
         }
<pre>private void timer1_Tick(object sender, EventArgs e)
         
{
             CallCustomer();
                CallCustomerError();
                lbl1.Text = "Process started.....";
                string source = "D:\\Excels";
                string destination = "D:\\Excelsuploaded";
                if (!(Directory.Exists(destination) && Directory.Exists(source)))
                    return;
                string[] Templateexcelfile = Directory.GetFiles(source);
                int filecount = Templateexcelfile.Length;
                foreach (string file in Templateexcelfile)
                {
                    uploadexcl(file);
                    lbl2.Text = counter.ToString();
                    counter = counter + 1;
                    fcount = fcount + 1;
                }
            }


<pre>
Posted
Updated 20-Jul-17 0:41am
Comments
F-ES Sitecore 20-Jul-17 7:29am    
You need to add timer logging before each line to give you a log that lets you work out how long each bit is taking to see where the bottleneck actually is. Given we can't do that there isn't anything we can advise on, especially when the important bits of code don't even seem to be listed (uploadexcl for example). There is no magic "make my code 10 times faster" setting, you have to analyse what you've got, find the bottlenecks then see what (if anything) can be done to improve those bottlenecks.

1 solution

Quote:
Can someone help me please.

Basically, no. The problem is that we have no idea what your uploadexcl method is doing, but the "upload" part implies the internet is involved. What you are doing is sending a serial stream of file to your server, one after the other, and that process can't be speeded up if the upload is taking the entire internet connection upload bandwidth - as it will by default. And upload speeds are normally a lot, lot slower that download: I get 40Mbps download, and 8Mbps upload. If your excel files are of a significant size (and that will depend on the row and cell count, as well as the cell content) then they could be taking a significant amount of time each.
Check the file sizes in bytes, check the upload speed of your connection, divide one by the other-times-10 (8 bits per byte, plus some for overhead) and you'll have the seconds per file. Then use the Stopwatch class to check how long uploadexcl takes for each file. If the numbers are close, you can't speed the process up except by improving your internet connection.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900