title: A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll
body: <p>Im new to c# client and server application, im working on a file upload client and server application. </p>
  
  <p>i can successfully upload my file name and file data to the server from the client application. but when i try to implement a new textbox that allow the file upload client to enter his/her name and send the information together with the file name and file data when he/her click the send button.</p>
  
  <p>client application.</p>
  
  <pre><code> /* file name and file length */
              byte[] fName = Encoding.UTF8.GetBytes(fileName);
              byte[] fNameLen = BitConverter.GetBytes(fileName.Length); // length of file name
              clientData = new byte[4 + fileName.Length];                
              System.Diagnostics.Debug.WriteLine("fName " + fName.Length);
              System.Diagnostics.Debug.WriteLine("fNamelen " + fNameLen.Length);
              fNameLen.CopyTo(clientData, 0);
              fName.CopyTo(clientData, 4);
  
              /* author name and author name length */
              byte[] aName = Encoding.UTF8.GetBytes(textBox2.Text);
              byte[] aNameLen = BitConverter.GetBytes(textBox2.Text.Length);
              System.Diagnostics.Debug.WriteLine("aName " + aName.Length);
              System.Diagnostics.Debug.WriteLine("aNamelen " + aNameLen.Length);
              authorData = new byte[9 + textBox2.Text.Length];
              aNameLen.CopyTo(authorData, 5);
              aName.CopyTo(authorData, 9);
  </code></pre>
  
  <p>server application</p>
  
  <pre><code>/* retriving of file name */
                 System.Diagnostics.Debug.WriteLine("Error 1");
                 fNameLen = BitConverter.ToInt32(state.buffer, 0);
                 System.Diagnostics.Debug.WriteLine("Error 2 fNameLen " + fNameLen);
                 string Filename = Encoding.UTF8.GetString(state.buffer, 4, fNameLen);
                 System.Diagnostics.Debug.WriteLine("Error 3");
                 System.Diagnostics.Debug.WriteLine("filename length " + fNameLen);
                 receivedPath = @"C:\testfiles\" + Filename;
                 System.Diagnostics.Debug.WriteLine("bytesREad1 " + bytesRead);
                 System.Diagnostics.Debug.WriteLine(receivedPath);
  
                 /* retriving of author name */
                 aNameLen = BitConverter.ToInt32(state.buffer, 5);
                 System.Diagnostics.Debug.WriteLine("Error 4");
                 System.Diagnostics.Debug.WriteLine("error  5");
                 System.Diagnostics.Debug.WriteLine("author name length " + aNameLen);
                 string authorName = ASCIIEncoding.ASCII.GetString(state.buffer, 9, aNameLen);
                 System.Diagnostics.Debug.WriteLine("Error 6");
                 System.Diagnostics.Debug.WriteLine("author name " + authorName);
                 System.Diagnostics.Debug.WriteLine("author name length " + aNameLen);
  </code></pre>
  
  <p>output window  and error given in bold:</p>
  
  <ul>
  <li>Error 1</li>
  <li>Error 2 fNameLen 12</li>
  <li>Error 3</li>
  <li>filename length 12</li>
  <li>bytesREad1 82</li>
  <li>C:\testfiles\Test1122.txt</li>
  <li>Error 4</li>
  <li>error  5</li>
  <li>author name length 829715301</li>
  <li><strong>A first chance exception of type 'System.ArgumentOutOfRangeException'
  occurred in mscorlib.dll</strong></li>
  </ul>
  
  <p>thank you in advance.</p>