/// <summary> /// Verifies the required files exist. If they do not and they have a file defination it will create the file. /// </summary> /// <returns>False if one of the MANDATORY files did not create</returns> public static bool Initialize() { bool noFailures = true; Type classType = typeof(FileLocations); foreach (PropertyInfo propertyInfo in classType.GetProperties()) { if (propertyInfo.PropertyType != typeof(FileLocationContainer)) { continue; } FileLocationContainer fileInfo = propertyInfo.GetValue(null) as FileLocationContainer; if (IoHelperMethods.FileExists(fileInfo.Path)) { continue; // Skip files that exist } // Try to create the file using the file defination if it has one if (fileInfo.FileDefination != null) { if (IoHelperMethods.CreateFile(fileInfo.Path, fileInfo.FileDefination, fileInfo.Required)) { continue; } } if (!fileInfo.Required) { continue; // if not required then continue because it's ok } noFailures = false; break; } return(noFailures); }
/// <summary> /// Create & verify each directory /// </summary> /// <returns>False if one of the directories did not create</returns> public static bool Initialize() { Type classType = typeof(DirectoryLocations); foreach (PropertyInfo propertyInfo in classType.GetProperties()) { //if (propertyInfo.PropertyType != typeof(string)) continue; // only get string properties string path = propertyInfo.GetValue(null).ToString(); // get path if (!IoHelperMethods.DirectoryExists(path) && !IoHelperMethods.CreateDirectory(path)) { return(false); } } return(true); }