Rano AH

Rano AH

  • NA
  • 176
  • 111.7k

How to ignore reading white spaces in text file

Sep 11 2013 1:18 AM

Hi Sunny Kumar and Vulpes

 Usually, I do get useful solution when you both reply my questions, then it would be nice if
 you reply my question also

 For the below code, how to ignore reading white spaces especially when each row in my text file begins with space.


if (Files.Lenght > 0)
foreach (string file in files)
{
try
{
var list = new List<string>();

 using (var reader = new StreamReader(file))
                        {
                            for (int i = 0; i < 10; i++)
                            {
                                list.Add(reader.ReadLine());
                            }
                        }
string newFileName = string.Concat(Path.GetFileNameWithoutExtension(file), "-",list[3], "-", list[8],"-",list[9],"-",list[10], "txt");
newFileName=Regex.Replace(newFileName, @"\*", "X");
newFileName = Regex.Replace(newFileName, @"\/", "");

string newFile = string.Concat(outputDirectory,"\\",newFileName,".txt");
File.Copy(file, newFile);


Answers (4)