title: Write BSON Document to a File
body: <p>How can I write all the data in a collection to an external text file? The following is the collection:</p>
  
  <pre><code>var collection = _database.GetCollection&lt;BsonDocument&gt;("clicks");
  </code></pre>