/// <summary> /// Checks that all the folders we define here are accessible, and if not /// creates them. If something goes wrong returns False. /// </summary> public static bool InitializeFolders() { foreach (string path in FoldersList) { if (!CheckAndCreateDir(path)) { LogTrace.Error("Unable to create folder {0}", path); return(false); } } LogTrace.Log("Folders initialized for {0}", DashboardPath); return(true); }
/// <summary> /// Checks to see if the given path directory exists, and if not tries to create. If all goes /// well returns true. If something goes wrong, false is returned. /// </summary> public static bool CheckAndCreateDir(string dirPath) { DirectoryInfo dir = new DirectoryInfo(dirPath); if (!dir.Exists) { try { Directory.CreateDirectory(dir.FullName); } catch (Exception e) { LogTrace.Error("Couldn't create directory {0}, Exception: {1}", dir.FullName, e.Message.ToString()); return(false); } } return(true); }