title: webclient.UploadData "The underlying Connection was Closed: An unexpected error occured on a recieve"
body: <p>I am trying to upload image and video using code below, there is no issue with image upload using ftp, but when I am uploading video I get the following error</p>
  
  <p><strong>Error</strong></p>
  
  <pre><code>The underlying connection was closed: An unexpected error occurred on a receive.
  </code></pre>
  
  <p>Following is the code I am using to upload</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code> try
              {
                  string uploadFileName = Path.GetFileName(FU_Video.FileName);
                  uploadFileName = "video." + uploadFileName.Split('.')[1];
                  using (WebClient client = new WebClient())
                  {
                      string ftpAddres = "ftp://username:pasword@url-path" + fullname;
  
                      if (!GetAllFilesList(ftpAddres, "username", "password"))
                      {
                          FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpAddres);
                          ftp.Method = WebRequestMethods.Ftp.MakeDirectory;
                          ftp.KeepAlive = false;
  
                          FtpWebResponse response = (FtpWebResponse)ftp.GetResponse();
                      }
                      client.UploadData(new Uri(ftpAddres + "/" + uploadFileName), FU_Video.FileBytes);
                  }
  </code></pre>
  
  <p>and here is the stack trace.</p>
  
  <p><strong>stack Trace</strong></p>
  
  <pre><code>   at System.Net.WebClient.UploadDataInternal(Uri address, String method, Byte[] data, WebRequest&amp; request)
     at System.Net.WebClient.UploadData(Uri address, String method, Byte[] data)
     at System.Net.WebClient.UploadData(Uri address, Byte[] data)
     at MentorMentee.SignUp.signup.btn_VidPreview_Click(Object sender, EventArgs e) in I:\VS Projects\code\MentorMentee1\MentorMentee\SignUp\signup.aspx.cs:line 469
  </code></pre>
  
  <p>after searching I read to make connection alive false, but I am getting error on line <code>client.UploadData(uri,byte[]);</code></p>
  
  <p>please let me know what is wrong with my code? as video is uploaded on ftp, but I get error.</p>