public static void SaveCourseware(Courseware courseware) { if (courseware.Title.IsNullOrEmpty()) { return; } var path = Path.Combine(ResourceDirectory, courseware.Root); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path = Path.Combine(path, CoursewareFileName); StreamWriter sw = File.CreateText(path); string data = courseware.ToJson(); sw.Write(data); sw.Flush(); sw.Close(); }