title: Best approach to write huge sql dataset into xml file?
body: <p>In C#,i have a huge dataset that i want to write it into xml file with write xml,that is my code:</p>
  
  <pre><code> using (var myConnection = new SqlConnection("Data Source=192.168.5.28;Initial Catalog=dbName;User ID=sa;Password=davood$;"))
          {
  
              var da = new SqlDataAdapter("select * from tblName", myConnection);
              var ds = new DataSet();
              da.Fill(ds);
              var filestream = File.Create("D:\\tblName.xml");
              var buffered = new BufferedStream(filestream);
              ds.WriteXml(buffered);
             // ds.WriteXml("D:\\tblName.xml", System.Data.XmlWriteMode.IgnoreSchema);
  
              //
              //using (var fileStream = File.Create("D:\\tblName.xml"))
              //{
              //    using (var zipStream = new GZipStream(fileStream, CompressionMode.Compress))
              //    {
              //        ds.WriteXml(zipStream, XmlWriteMode.WriteSchema);
              //    }
              //}
          }
  </code></pre>
  
  <p>but after program is execute(with long time executing),file is can not be open.
  Tnx.</p>