public static void Start() { OpenFileDialog ofd = new OpenFileDialog { Filter = "Text File|*.txt|Gen File|*.gen|All|*.*", Multiselect = true }; ofd.ShowDialog(); if (ofd.FileNames.Length == 0) { return; } for (int i = 0; i < ofd.FileNames.Length; i++) { var MonGen = File.ReadAllLines(ofd.FileNames[i]); for (int j = 0; j < MonGen.Length; j++) { if (MonGen[j].Contains(';')) { MonGen[j] = MonGen[j].Substring(0, MonGen[j].IndexOf(";", System.StringComparison.Ordinal)); } var Line = System.Text.RegularExpressions.Regex.Replace(MonGen[j], @"\s+", " ").Split(' '); if (Line.Length < 7) { continue; } try { MonGenInfo MonGenItem = new MonGenInfo { Map = Line[0], X = Convert.ToInt16(Line[1]), Y = Convert.ToInt16(Line[2]), Name = Line[3], Range = Convert.ToInt16(Line[4]), Count = Convert.ToInt16(Line[5]), Delay = Convert.ToInt16(Line[6]), Direction = (Line.Length == 8) ? Convert.ToInt16(Line[7]) : 0 }; monGenList.Add(MonGenItem); } catch (Exception) { continue; } } } }
public static void Start() { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Text File|*.txt|Gen File|*.gen|All|*.*"; ofd.Multiselect = true; ofd.ShowDialog(); if (ofd.FileNames.Length == 0) return; for (int i = 0; i < ofd.FileNames.Length; i++) { var MonGen = File.ReadAllLines(ofd.FileNames[i]); for (int j = 0; j < MonGen.Length; j++) { if (MonGen[j].Contains(';')) MonGen[j] = MonGen[j].Substring(0, MonGen[j].IndexOf(";", System.StringComparison.Ordinal)); var Line = System.Text.RegularExpressions.Regex.Replace(MonGen[j], @"\s+", " ").Split(' '); if (Line.Length < 7) continue; try { MonGenInfo MonGenItem = new MonGenInfo { Map = Line[0], X = Convert.ToInt16(Line[1]), Y = Convert.ToInt16(Line[2]), Name = Line[3], Range = Convert.ToInt16(Line[4]), Count = Convert.ToInt16(Line[5]), Delay = Convert.ToInt16(Line[6]), Direction = (Line.Length == 8) ? Convert.ToInt16(Line[7]) : 0 }; monGenList.Add(MonGenItem); } catch (Exception) { continue; } } } }