My File.txt has this form and I want to delete the blank rows
10203040 F B B B B B A A X A C 10209647 F C A B B B B B A B A 10217686 F B B A A A A B B X B 10224729 M B A A X B C A A A X
My File.txt has this form and I want to delete the blank rows
10203040 F B B B B B A A X A C 10209647 F C A B B B B B A B A 10217686 F B B A A A A B B X B 10224729 M B A A X B C A A A X
Good morning, You could use some LinQ to filter them, I'll give you an example
static void RemoveWhiteLines(string strSourcePath,string strDestinePath)
{
//Lee todas las lineas del fichero
string[] strAllLines = File.ReadAllLines(strSourcePath);
//Selecciona las lineas que no sean null o blancas
string[] strWritedLines = strAllLines.Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
//Guarda las nuevas lineas en el nuevo fichero
File.WriteAllLines(strDestinePath, strWritedLines);
}
You could simplify it more too
static void RemoveWhiteLines(string strSourcePath,string strDestinePath)
{
//Lee todas las lineas del fichero
string[] strAllLines = File.ReadAllLines(strSourcePath);
//Selecciona las lineas que no sean null o blancas
//Guarda las nuevas lineas en el nuevo fichero
File.WriteAllLines(strDestinePath, strAllLines.Where(x => !string.IsNullOrWhiteSpace(x)).ToArray());
}
What the program does is read all the lines of the path that you indicate, delete the blank lines, and save them in the other file that you indicate, but you could return them, or what interests you.
Atte