Example #1
0
        public bool Read(string file, FileShare fs = FileShare.None)
        {
            Rows = new List <Row>();

            if (!File.Exists(file))
            {
                return(false);
            }

            try
            {
                using (Stream s = File.Open(file, FileMode.Open, FileAccess.Read, fs))
                {
                    using (StreamReader sr = new StreamReader(s))
                    {
                        CVSRead cvs = new CVSRead(sr);

                        CVSRead.State st;

                        Row l = new Row();

                        string str;
                        while ((st = cvs.Next(out str)) != CVSRead.State.EOF)
                        {
                            l.Cells.Add(str);

                            if (st == CVSRead.State.ItemEOL)
                            {
                                Rows.Add(l);
                                l = new Row();
                            }
                        }

                        if (l.Cells.Count > 0)
                        {
                            Rows.Add(l);
                        }

                        return(true);
                    }
                }
            }
            catch
            {
                return(false);
            }
        }
Example #2
0
        public bool Read(string file)
        {
            rows = new List <Line>();

            try
            {
                using (Stream s = File.OpenRead(file))
                {
                    using (StreamReader sr = new StreamReader(s))
                    {
                        CVSRead cvs = new CVSRead(sr);

                        CVSRead.State st;

                        Line l = new Line();

                        string str;
                        while ((st = cvs.Next(out str)) != CVSRead.State.EOF)
                        {
                            l.cells.Add(str);

                            if (st == CVSRead.State.ItemEOL)
                            {
                                rows.Add(l);
                                l = new Line();
                            }
                        }

                        if (l.cells.Count > 0)
                        {
                            rows.Add(l);
                        }

                        return(true);
                    }
                }
            }
            catch
            {
                return(false);
            }
        }