static void TinhCK_Ghep(string Sf, int k, int Ntt, ref long Ts) { StreamReader F_In; StreamWriter F_O; string Ss1, Ss2, Ss3, S, S1, S2, S3, S4, S5; int j, L1; bool Tiep; Ss1 = "" + (k - 1); Ss2 = "" + Ntt; Ss3 = "" + k; F_In = new StreamReader(@"TTX_" + Sf + "_" + Ss1 + "_" + Ss2 + ".Txt"); F_O = new StreamWriter(@"TKN_" + Sf + "_" + Ss3 + "_" + Ss2 + ".Txt", false); L1 = 0; Ts = 0; Console.WriteLine("\t ♦ Dang ghep cac tap thuong xuyen ", k - 1, " muc du lieu"); while ((S1 = F_In.ReadLine()) != null) { S2 = S1; S3 = ""; for (j = 1; j <= k - 2; j++) { S3 = S3 + S2.Substring(0, S2.IndexOf(";") + 1); S2 = S2.Remove(0, S2.IndexOf(";") + 1); } Tiep = !F_In.EndOfStream; while ((!F_In.EndOfStream) && Tiep) { S4 = F_In.ReadLine(); S5 = ""; for (j = 1; j <= k - 2; j++) { S5 = S5 + S4.Substring(0, S4.IndexOf(";") + 1); S4 = S4.Remove(0, S4.IndexOf(";") + 1); } if (S3 == S5) { Ts = Ts + 1; F_O.WriteLine(S1 + S4); Tiep = true; if (Ts % 1000 == 0) { Console.Write(Ts + "\t"); } } else { Tiep = false; } } F_In.BaseStream.Seek(0, SeekOrigin.Begin); L1 = L1 + 1; for (j = 1; j <= L1; j++) { S = F_In.ReadLine(); } } F_Ketqua.WriteLine("Co " + Ts + " tap " + k + " muc du lieu duoc ghep"); F_In.Close(); F_O.Close(); }