private List <MySchemaInfor> GetTable(IDataReader dr) { var list = new List <MySchemaInfor>(); while (dr.Read()) { MySchemaInfor info = new MySchemaInfor(); info.Database = dr[0].ToString(); info.DataType = dr[1].ToString(); info.ColumnType = dr[2].ToString(); info.TableName = dr[3].ToString(); list.Add(info); } return(list); }
public void CreateFile(StringBuilder sb, StringBuilder Isb, MySchemaInfor itemtable, string extention) { Tuple <string, StringBuilder> path = new Tuple <string, StringBuilder>(string.Format("{0}\\{1}.{2}", FolderPath.Text, itemtable.TableName, extention), sb); Tuple <string, StringBuilder> Ipath = new Tuple <string, StringBuilder>(string.Format("{0}\\I{1}.{2}", FolderPath.Text, itemtable.TableName, extention), Isb); Tuple <string, StringBuilder> [] Paths = { path, Ipath }; foreach (var item in Paths) { try { // Delete the file if it exists. if (File.Exists(item.Item1)) { File.Delete(item.Item1); } // Create the file. using (FileStream fs = File.Create(item.Item1)) { Byte[] info = new UTF8Encoding(true).GetBytes(item.Item2.ToString()); // Add some information to the file. fs.Write(info, 0, info.Length); } // Open the stream and read it back. using (StreamReader sr = File.OpenText(item.Item1)) { string s = ""; while ((s = sr.ReadLine()) != null) { Console.WriteLine(s); } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } } }