Search
 
SCRIPT & CODE EXAMPLE
 

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);
        }
    }
}
Comment

delete the particular line in files in c#

string line = null;
string line_to_delete = "the line i want to delete";

using (StreamReader reader = new StreamReader("C:input")) {
    using (StreamWriter writer = new StreamWriter("C:output")) {
        while ((line = reader.ReadLine()) != null) {
            if (String.Compare(line, line_to_delete) == 0)
                continue;

            writer.WriteLine(line);
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: HCF of list of number 
Csharp :: or c# 
Csharp :: how to select time and date in datetimepicker in c# 
Csharp :: vector3 unity 
Csharp :: c# convert string array to int array 
Csharp :: difference between boxing and unboxing in java 
Csharp :: c# array.join 
Csharp :: c# get all namespaces in assembly 
Csharp :: arcane 
Csharp :: wpf toolbar disable overflow 
Csharp :: c# dictionary with multiple values 
Csharp :: disable button in android studio 
Csharp :: set target framerate unity 
Csharp :: C# clear console input buffer 
Csharp :: c# get custom attribute from property 
Csharp :: modulus program 
Csharp :: unity get gameobject from hit 
Csharp :: c# wpf image source from resource programmatically 
Csharp :: from string 
Csharp :: c# regex find last match 
Csharp :: And this is how can you deserialize your XML file in your C# code: 
Csharp :: custom click event wpf button 
Csharp :: compact in laravrl 
Csharp :: get the number of cpu c# 
Csharp :: c# yield 
Csharp :: to list c# 
Csharp :: element click intercepted exception in selenium C# 
Csharp :: c# wpf row definition height * in code 
Csharp :: window height in C# forms 
Csharp :: remove header visual studio android 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =