public static void ReadFile() { string DeviceName; string TableConfig; using (System.IO.StreamReader file = new System.IO.StreamReader(@"D:\jinchen\projects\webapi2\source1.txt", true)) { try { int counter = 0; string line; while ((line = file.ReadLine()) != null) { // System.Console.WriteLine(line); string[] sA = line.Split('\t'); int ln = sA.Length; if (ln > 0) { DeviceName = sA[0] as string; DeviceName = DeviceName.Trim(); if (DeviceName == "") { continue; } if (ln > 1) { for (int i = 1; i < ln; i++) { TableConfig = sA[i] as string; TableConfig = TableConfig.Trim(); if (TableConfig == "") { continue; } Console.Write(DeviceName + " "); GenerateSQLFile(DeviceName, TableConfig); Console.Write(TableConfig + " "); Console.WriteLine(" "); counter++; } } } } Console.WriteLine(counter); } catch (System.NullReferenceException e) { file.Close(); } } }