コード例 #1
0
        public void SaveToFile(string directoryPath, string fileName, CourseReport report)
        {
            if (!Directory.Exists(directoryPath))
            {
                Directory.CreateDirectory(directoryPath);
            }

            File.WriteAllText(Path.Combine(directoryPath, fileName), report.ToString());
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var report = new CourseReport();

            report.AddEntry(new CourseReportEntry {
                Name = "Patrones de diseño", Students = 1000, Rating = 5
            });
            report.AddEntry(new CourseReportEntry {
                Name = "Flutter", Students = 1900, Rating = 4.5
            });

            Console.WriteLine(report.ToString());
            ReportPrint.SaveToFile(@"Reports", "WorkReport.txt", report.ToString());
        }