public static void Write_Rebar_Weights(Rebar_Weights list) { Rebars = list; string table_file = ASTRA_Table_Path; table_file = Path.Combine(Path.GetDirectoryName(table_file), "Rebar_Weights.txt"); //table_file = Path.Combine(table_file, "Rebar_Weights.txt"); if (File.Exists(table_file)) { List <string> content = new List <string>(); MyList mlist; content.Add(string.Format("")); content.Add(string.Format("---------------------")); content.Add(string.Format("Bar Dia WEIGHT")); content.Add(string.Format(" (mm) (Ton/m)")); content.Add(string.Format("---------------------")); //list.Add(string.Format(" 6 0.000222")); //list.Add(string.Format(" 8 0.000395")); for (int i = 0; i < list.Count; i++) { try { content.Add(string.Format("{0,4} {1,15:f6}", list[i].Size, list[i].Weight)); } catch (Exception ex) { } } content.Add(string.Format("---------------------")); File.WriteAllLines(table_file, content.ToArray()); } }
public static Rebar_Weights Get_Rebar_Weights() { string table_file = ASTRA_Table_Path; table_file = Path.Combine(Path.GetDirectoryName(table_file), "Rebar_Weights.txt"); Rebar_Weights list = new Rebar_Weights(); if (File.Exists(table_file)) { List <string> content = new List <string>(File.ReadAllLines(table_file)); MyList mlist; for (int i = 0; i < content.Count; i++) { try { mlist = new MyList(MyList.RemoveAllSpaces(content[i]), ' '); if (mlist.Count == 2) { list.Add(new Rebar_Weight(mlist.GetInt(0), mlist.GetDouble(1))); } } catch (Exception ex) { } } } Rebars = list; return(list); }