title: How do I append to a file in an Azure storage file share?
body: <p>I want to write entries to a log file stored in Azure file storage. I currently have this:</p>
  
  <pre><code>var log = "My log entry";
  
  var client = _storageAccount.CreateCloudFileClient();
  var share = client.GetShareReference(Config.LogShare);
  share.CreateIfNotExists();
  var root = share.GetRootDirectoryReference();
  var logfile = root.GetFileReference("log.txt");
  if (!logfile.Exists()) logfile.Create(0);
  
  // What goes here to append to the file...?
  </code></pre>
  
  <p>I can see plenty of examples of how to do this with Blobs, or how to upload an entire file, but how do I just append to an existing file?</p>
  
  <p>I have tried this:</p>
  
  <pre><code>var buffer = Encoding.GetEncoding("UTF-8").GetBytes(log.ToCharArray());
  
  using (var fileStream = logfile.OpenWrite(0)) {
      fileStream.Write(buffer, (int)logfile.Properties.Length, buffer.Length);
  }
  </code></pre>
  
  <p>But then I get this error:</p>
  
  <pre><code>The remote server returned an error: (416) The range specified is invalid for the current size of the resource..
  </code></pre>