コード例 #1
0
    public static void Load(string path, FileDB db)
    {
        ConsoleUtil.WriteColor(String.Format("Loading '{0}'...\n", path), ConsoleColor.White);
        db.ResetFileStatistics();

        try
        {
            bool firstLine = true;
            foreach (string line in File.ReadLines(path))
            {
                if (firstLine)
                {
                    firstLine = false;   // And do nothing more with the first line which contains the header of column labels
                }
                else
                {
                    FileDescription fd = FileDescription.ParseRecord(line);
                    if (fd != null)
                    {
                        db.AddRecord(fd);
                    }
                }
            }
        }
        catch (Exception e)
        {
            ConsoleUtil.WriteLineColor(String.Format("*** Exception loading report file '{0}' - {1}", path, e.Message),
                                       ConsoleColor.Red);
        }
    }