Exemple #1
0
        public void buildlist(string filename)
        {
            try
            {
                using (StreamReader readFile = new StreamReader(filename))
                {
                    string   line;
                    string[] row = new string[3];

                    double xloc;
                    double yloc;
                    int    hopp;

                    while ((line = readFile.ReadLine()) != null)
                    {
                        row = line.Split(',');

                        bool trashLine = false;

                        if (!Double.TryParse(row[0], out xloc))
                        {
                            trashLine = true;
                        }
                        if (!Double.TryParse(row[1], out yloc))
                        {
                            trashLine = true;
                        }
                        if (!Int32.TryParse(row[2], out hopp))
                        {
                            trashLine = true;
                        }

                        //Debugging purposes only.
                        //string msg = row[0] + " | " + row[1] + " | " + row[2] + " | " + trashLine.ToString();
                        //MessageBox.Show(msg);

                        if (!trashLine)
                        {
                            weldedStud ws = new weldedStud(xloc, yloc, hopp);
                            inter_studList.Add(ws);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                string errmsg = e.Message + " | Filename = " + filename;
                MessageBox.Show(errmsg);
            }
        }
        public void buildlist(string filename)
        {
            try
            {
                using (StreamReader readFile = new StreamReader(filename))
                {
                    string line;
                    string[] row = new string[3];

                    double xloc;
                    double yloc;
                    int hopp;

                    while ((line = readFile.ReadLine()) != null)
                    {
                        row = line.Split(',');

                        bool trashLine = false;

                        if(!Double.TryParse(row[0], out xloc))
                            trashLine = true;
                        if(!Double.TryParse(row[1], out yloc))
                            trashLine = true;
                        if (!Int32.TryParse(row[2], out hopp))
                            trashLine = true;

                        //Debugging purposes only.
                        //string msg = row[0] + " | " + row[1] + " | " + row[2] + " | " + trashLine.ToString();
                        //MessageBox.Show(msg);

                        if (!trashLine)
                        {
                            weldedStud ws = new weldedStud(xloc, yloc, hopp);
                            inter_studList.Add(ws);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                string errmsg = e.Message + " | Filename = " + filename;
                MessageBox.Show(errmsg);
            }
        }