Connection timeout error while uploading bulk images
<p>I have to upload 1000 to 1500 images at a time on server.. Code is as follows.</p>

<pre><code>public void add_data()
{
 DataSet ds = new DataSet();
                ds = get_Data();
                int p = 0;
                if (ds.Tables.Count &gt; 0)
                {
                    if (ds.Tables[0].Rows.Count &gt; 0)
                    {
                        int cnt = ds.Tables[0].Rows.Count;
                        while (cnt &gt; 0)
                        {

                            string url = Convert.ToString(ds.Tables[0].Rows[p]["image_name"]);
                            string imagename = url.Substring(url.LastIndexOf('/') + 1);
                            string file_name = imagename;

                            save_file_from_url(file_name, url);
                            p++;
                            cnt = cnt - 1;
                        }
                    }
                }
}



public void save_file_from_url(string file_name, string url)
    {
        if (!File.Exists(file_name))
        {

            try
            {
                byte[] imgcontent;
                //Convert live images into byte array to pass it for ftp server
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                WebResponse response = request.GetResponse();

                Stream stream = response.GetResponseStream();

                using (BinaryReader br = new BinaryReader(stream))
                {
                    imgcontent = br.ReadBytes(500000);
                    br.Close();
                }
                response.Close();

                string CompleteDPath = "www.xyz.com";
                string UName = "abc";
                string PWD = "pwd";
                WebRequest reqObj = WebRequest.Create(CompleteDPath + file_name);
                reqObj.Method = WebRequestMethods.Ftp.UploadFile;
                reqObj.Credentials = new NetworkCredential(UName, PWD);
                reqObj.GetRequestStream().Write(imgcontent, 0, imgcontent.Length);
                reqObj = null;


            }
            catch (Exception ex)
            {
                lblmessage.ForeColor = System.Drawing.Color.Red;
                lblmessage.Text = ex.Message;
            }
        }
    }
</code></pre>

<p>But it gives following error that</p>

<p>The following error was encountered:</p>

<pre><code>Read Timeout 
</code></pre>

<p>The system returned:</p>

<pre><code>[No Error]
</code></pre>

<p>A Timeout occurred while waiting to read data from the network. The network or server may be down or congested. Please retry your request.</p>

<p>Your cache administrator is webmaster.</p>

<p>What should i use? Please help!</p>
