creating a CSV file with titles

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jw01
    New Member
    • Dec 2006
    • 19

    creating a CSV file with titles

    Hi,

    I have a csv file stored up in my computer and my program writes to that csv file:

    File1 = IO.File.AppendT ext("D:\Profile s\(compname)\De sktop\Web_Submi ssion_Project\u pdated_document .csv")
    'Write a line to the bottom
    File1.WriteLine (Trim(ProjectTe xtBox.Text) & "," & NotesTextBox.Te xt & "," & ProjectDetail2T extBox.Text & "," & ProjectDetail3T extBox.Text)

    But now I want to create my own csv file. i.e my code should generate tht csv file and then write to it.

    Can someone plz help me in this regrd
  • chinu
    New Member
    • Jun 2007
    • 36

    #2
    Originally posted by jw01
    Hi,

    I have a csv file stored up in my computer and my program writes to that csv file:

    File1 = IO.File.AppendT ext("D:\Profile s\(compname)\De sktop\Web_Submi ssion_Project\u pdated_document .csv")
    'Write a line to the bottom
    File1.WriteLine (Trim(ProjectTe xtBox.Text) & "," & NotesTextBox.Te xt & "," & ProjectDetail2T extBox.Text & "," & ProjectDetail3T extBox.Text)

    But now I want to create my own csv file. i.e my code should generate tht csv file and then write to it.

    Can someone plz help me in this regrd
    Check whether this is what you were looking at
    string path = "C:\\testing\\c svtest.csv";
    if (!File.Exists(p ath))
    {
    using (StreamWriter sw = File.CreateText (path))
    {
    sw.WriteLine("u r data in CSV");
    }
    }
    else
    {
    using (StreamWriter sw = File.AppendText (path))
    {
    sw.WriteLine("M y data");
    }
    }

    It is in C#, but you can easily convert to VB if u want.

    Comment

    Working...