title: Uploading files to file server
body: <p>Using the link below, I wrote a code for my application. I am not able to get it right though, Please refer the link and help me ot with it...</p>
  
  <p><a href="https://stackoverflow.com/questions/263518/c-uploading-files-to-file-server">Uploading files to file server using webclient class</a></p>
  
  <hr>
  
  <p>The following is my code:-</p>
  
  <pre><code>protected void Button1_Click(object sender, EventArgs e)
  {
  
      filePath = FileUpload1.FileName;    
      try
      {
          WebClient client = new WebClient();
  
          NetworkCredential nc = new NetworkCredential(uName, password);
  
          Uri addy = new Uri("\\\\192.168.1.3\\upload\\");
          client.Credentials = nc;
          byte[] arrReturn = client.UploadFile(addy, filePath);
  
          Console.WriteLine(arrReturn.ToString());
      }
      catch (Exception ex)
      {
          Console.WriteLine(ex.Message);
      }
  
  }
  </code></pre>
  
  <p>I also used:-
  File.Copy(filePath, "\\192.168.1.3\upload\");</p>
  
  <p>The following line doesn't execute...</p>
  
  <pre><code>byte[] arrReturn = client.UploadFile(addy, filePath);
  </code></pre>
  
  <p>tried changing it to:-</p>
  
  <pre><code>byte[] arrReturn = client.UploadFile("\\\\192.168.1.3\\upload\\", filePath);
  </code></pre>
  
  <p>IT still doesn't work...Any solution to it??</p>
  
  <p>I basically want to transfer a file from the client to the file storage server without 
  actually login into the server so that the client cannot access the storage location 
  on the server directly.</p>
  
  <p>THIS IS THE ERROR I GET :- <strong>"An exception occurred during a WebClient request"</strong></p>