none
Delete a file from csv using windows form in C# RRS feed

Answers

  • Hi Arun,

    You could do the following,

    List linesList = File.ReadAllLines("testFile.csv").ToList();
    
    linesList.RemoveAt(0); //Here enter the line number you want to delete
    
    File.WriteAllLines("testFile.csv"), linesList.ToArray());


    You just put the line number you want to delete in the second line of the code and its done.

    Thanks,

    Sabah Shariq

    Wednesday, September 30, 2015 12:32 PM

All replies

  • Do you mean how to delete a CSV file? Or how to delete a single line of text from a file that is in CSV format?
    Wednesday, September 30, 2015 10:08 AM
  • Yeah To Delete a single row from a CSV file
    Wednesday, September 30, 2015 11:23 AM
  • Yes I need To Delete a single line from a csv file while using WinForms in C#
    Wednesday, September 30, 2015 11:25 AM
  • Hi Arun,

    You could do the following,

    List linesList = File.ReadAllLines("testFile.csv").ToList();
    
    linesList.RemoveAt(0); //Here enter the line number you want to delete
    
    File.WriteAllLines("testFile.csv"), linesList.ToArray());


    You just put the line number you want to delete in the second line of the code and its done.

    Thanks,

    Sabah Shariq

    Wednesday, September 30, 2015 12:32 PM
  • Thanks Sabah Shariq, Let me try this 
    Wednesday, September 30, 2015 1:25 PM