Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

delete the particular line in files in c#

string line = null;
int line_number = 0;
int line_to_delete = 12;

using (StreamReader reader = new StreamReader("C:input")) {
    using (StreamWriter writer = new StreamWriter("C:output")) {
        while ((line = reader.ReadLine()) != null) {
            line_number++;

            if (line_number == line_to_delete)
                continue;

            writer.WriteLine(line);
        }
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #delete #line #files
ADD COMMENT
Topic
Name
9+4 =