title: Create File on fly and upload it in SharePoint in C#
body: <p>I want to  write in MemoryStream and then put/ upload the same in Shared documents in Sharepoint Below is the code I am trying:-</p>
  
  <pre><code> var clientContext = new ClientContext("https://server.info/");
  
                  string fileUrl = "/Shared Documents/NewDocumentFromTemplate.txt";
  
                  var ms = new MemoryStream();
                  using (var file = new StreamWriter(ms))
                  {
  
                      file.WriteLine("Wrinting in file");
                  }
  
                  Microsoft.SharePoint.Client.File.SaveBinaryDirect(clientContext, fileUrl, ms, true);
  </code></pre>
  
  <p>Its actually creating a new file as NewDocumentFromTemplate.txt but it is empty. Its not writing anything.  :(</p>
  
  <p>Actuallly I want to create a file on fly and then upload it in share point.</p>
  
  <p>Please help I am first time working with Share Point client.</p>