add header for .csv

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • doubtful1
    New Member
    • Jun 2015
    • 2

    add header for .csv

    I want to add header for my .csv file.Code snippet is here.The problem is.my code only prints first heading on all columns.
    Can you please help whats wrong.It only prints DeviceIdent in all columns.I want to see all columns in proper heading.
    Code:
    string fileLocation = @"C:\Data\Test.csv";
    
              
                 if (!File.Exists(fileLocation))
                      {
                           File.Create(fileLocation).Close();
                       }
                string header =( "DeviceIdent" + "," + "Chipset" + "," + "Manufacturer" + "," + "Model" + "," + "Name" ) + Environment.NewLine;
    
                 
                File.AppendAllText(fileLocation, header);
    Last edited by Rabbit; Jun 3 '15, 03:46 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
Working...