How to read and compare single line from a File with another File
public void Main()
{
string Dpath = @"D:\SourceFiles\Customer\Sale_Files\";
string wpath=@"SourceFiles\Customer\Sale_Files\Files.csv";
StreamWriter wr = new StreamWriter(wpath);
DirectoryInfo dirInfo = new DirectoryInfo(Dpath); // directory informations
foreach (FileInfo f in dirInfo.GetFiles()) // file informations from that directory
{
StreamReader rd = new StreamReader(f.FullName); //get full filename
string line1;
line1 = rd.ReadLine(); // Read Single line from File
wr.WriteLine(line1);
MessageBox.Show(f.FullName);
foreach (FileInfo f2 in dirInfo.GetFiles())
{
StreamReader rd1 = new StreamReader(f2.FullName);
string line2;
line2 = rd1.ReadLine();
bool result = line1.Equals(line2, StringComparison.OrdinalIgnoreCase); //Comparison with line1 and line2
if (result == false)
{
MessageBox.Show(f2.FullName);
}
}
}
}
No comments:
Post a Comment