title: C# UnauthorizedAccessException error
body: <p>I am transfering files through sockets. When I try to save files to a custom directory, I get this error using BinaryWrite function.</p>
  
  <pre><code>private void downloadFromServer()
  {
     try
     {
        byte[] buffer = new byte[5000 * 1024];
        byte[] incomingFile = new byte[5000 * 1024];
        buffer = Encoding.Default.GetBytes(getUserName.Text + "Download" 
           + getFileName.Text + "end");
        clientSocket.Send(buffer);
        activityLog.AppendText("Preparing to download... \n");
        while (incomingFile != null)
        {
           clientSocket.Receive(incomingFile);
  
           int receivedBytesLen = incomingFile.Length;
           int fileNameLen = BitConverter.ToInt32(incomingFile, 0);
           File.WriteAllBytes(fileDir, incomingFile);
        } 
        activityLog.AppendText("File saved to " + fileDir + "\n");
     }
     catch (Exception ex)
     {
        MessageBox.Show(ex.Message);
     }
  }
  </code></pre>