title: Creating a CSV file
body: <p>I am calling a web service and getting all the data in a byte array. Now, I want to keep all this data in the CSV file. </p>
  
  <p>When I try to write the below code, it says, file is courrupted. But even after the warning I open up, it gets saved in Excel format.</p>
  
  <p>Can anyone guide me on this?</p>
  
  <pre><code>string delimiter = ",";
  matrixserverpath  == //web service call
  string filePath = @"\\test.net\excel\docs\file1.csv"; //trying to create this
  
  if (!System.IO.File.Exists(filePath))
  {
       System.IO.File.Create(filePath).Close();
  }
  
  System.Net.WebClient client = new System.Net.WebClient();
  WebDownload w = new WebDownload(3600000);
  UTF8Encoding objUTF8 = new UTF8Encoding();
  byte[] data = w.DownloadData(matrixserverpath + PRD);
  
  StringBuilder sb = new StringBuilder();
  for (int index = 0; index &lt; data.Length; index++)
      sb.AppendLine(string.Join(delimiter, data[index]));
  System.IO.File.AppendAllText(filePath, sb.ToString());
  </code></pre>
  
  <p>I want to save in a CSV file format, but it stores in Excel format.</p>