title: How do I Create a CSV file in C#
body: <p>I am new to file system. I need to create a simple csv file and need to write string in the file and read it back. </p>
  
  <p>I am getting some unicode value in the file that got created. How do i write string value by creating csv and reading back from it.</p>
  
  <p>So far I have wrote this. Need little hele here. </p>
  
  <p>Below is my code.</p>
  
  <pre><code>        static void Main()
      {
          string folderName = @"D:\Data";
          string pathString = System.IO.Path.Combine(folderName, "SubFolder");
          System.IO.Directory.CreateDirectory(pathString);
          string fileName = System.IO.Path.GetRandomFileName();
          pathString = System.IO.Path.Combine(pathString, fileName);
          Console.WriteLine("Path to my file: {0}\n", pathString);
  
          if (!System.IO.File.Exists(pathString))
          {
              using (System.IO.FileStream fs = System.IO.File.Create(pathString))
              {
                  {
                      byte a = 1;
                      fs.WriteByte(a);
                  }
              }
          }
  
          // Read and display the data from your file.
          try
          {
              byte[] readBuffer = System.IO.File.ReadAllBytes(pathString);
              foreach (byte b in readBuffer)
              {
                  Console.Write(b + " ");
              }
              Console.WriteLine();
          }
          catch (System.IO.IOException e)
          {
              Console.WriteLine(e.Message);
          }
      }
  </code></pre>