Esempio n. 1
0
File: Program.cs Progetto: qiuhy/zj
        public static List <Bill> readFile(string fn, int skipRows, Str2Bill toBill)
        {
            List <Bill> billList = new List <Bill>();
            Encoding    encode   = CommUtil.GetFileEncoding(fn);

            using (FileStream fs = new FileStream(fn, FileMode.Open))
            {
                StreamReader sr   = new StreamReader(fs, encode);
                int          irow = 0;
                while (!sr.EndOfStream)
                {
                    string sLine = sr.ReadLine();
                    irow++;

                    if (irow > skipRows)
                    {
                        Bill b = toBill(sLine);
                        if (b != null)
                        {
                            if (b.id == 0)
                            {
                                b.id = irow - skipRows;
                            }
                            billList.Add(b);
                        }
                    }
                }
                sr.Close();
            }
            billList.Sort();
            return(billList);
        }