/// <summary> /// Writes Searchs folder configs /// </summary> internal static void VERIFY_Search_Default_Files_Ready()//Writes Searchs.txt defaults { if (!CHECK_if_File_Exists(Settings.GET_SearchTermsFile_Path)) { CREATE_NEW_Files_And_Dirs(Settings.Search_File_Location, Settings.SearchTermsFileName_FileName, GET_Default_Logs_Search_File_Contents); Crypto_Operation.Secure_File(Settings.GET_SearchTermsFile_Path); } if (!CHECK_if_File_Exists(Settings.GET_WhiteList_SearchTermsFile_Path)) { CREATE_NEW_Files_And_Dirs(Settings.Search_File_Location, Settings.Search_WhiteList_FileName, GET_Default_Whitelist_File_Contents); Crypto_Operation.Secure_File(Settings.GET_WhiteList_SearchTermsFile_Path); } }
internal static List <string> READ_File_In_List(string FilePath) { if (CHECK_File_Encrypted(FilePath) == true) { Crypto_Operation.UnSecure_File(FilePath); List <string> TEMP_Contents = File.ReadAllLines(FilePath).ToList(); Crypto_Operation.Secure_File(FilePath); return(TEMP_Contents); } else { return(File.ReadAllLines(FilePath).ToList()); } }
internal static string[] READ_File_In_StringArray(string FilePath) { if (CHECK_if_File_Exists(FilePath)) { Crypto_Operation.UnSecure_File(FilePath); string[] Contents = File.ReadAllLines(FilePath); Crypto_Operation.Secure_File(FilePath); return(Contents); } else { Error_Operation.Log_Error("READ_File_In_StringArray()", "File not found " + FilePath, "", Error_Operation.LogSeverity.Informataion); return(File.ReadAllLines(FilePath)); } }
internal static void APPEND_Data_To_File(string FilePath, string Values) { if (CHECK_if_File_Exists(FilePath)) { if (CHECK_Data_Encrypted(FilePath)) { Crypto_Operation.UnSecure_File(FilePath); File.AppendAllText(FilePath, Values); Crypto_Operation.Secure_File(FilePath); } else { File.AppendAllText(FilePath, Values); } } }
internal static void UPDATE_Local_Config_With_Central_Config(string WebPath, string LocalPath, string FileName) { if (string.IsNullOrEmpty(Central_Config_File_Web_Cache)) { File_Operation.DELETE_File(LocalPath); //remove old config file Wclient.DownloadFile(WebPath, LocalPath); //if match read local files } else { File_Operation.DELETE_File(LocalPath);//remove old config file File_Operation.APPEND_AllTXT(LocalPath, Central_Config_File_Web_Cache); } Error_Operation.Log_Error("GET_Central_Config_File()", "Updated " + FileName + " from " + WebPath + ". It was downloaded to " + LocalPath, "", Error_Operation.LogSeverity.Verbose, Error_Operation.EventID.SWELF_Central_Config_Changed);//log change if (File_Operation.CHECK_File_Encrypted(LocalPath) == false) { Crypto_Operation.Secure_File(LocalPath); } }
/// <summary> /// Writes CONSOLEAPPCONFIG default configs /// </summary> internal static void VERIFY_AppConfig_Default_Files_Ready()//Writes default CONSOLEAPPCONFIG default configs { if (!CHECK_if_File_Exists(Settings.GET_AppConfigFile_Path)) { CREATE_NEW_Files_And_Dirs(Settings.Config_File_Location, Settings.AppConfigFile_FileName, GET_Default_ConsoleAppConfig_File_Contents); Crypto_Operation.Secure_File(Settings.GET_AppConfigFile_Path); } if (!CHECK_if_File_Exists(Settings.GET_EventLogID_PlaceHolder_Path))//eventlogplaceholder { CREATE_NEW_Files_And_Dirs(Settings.Config_File_Location, Settings.EventLogID_PlaceHolde_FileName, GET_Default_Eventlog_with_PlaceKeeper_File_Contents); Crypto_Operation.Secure_File(Settings.GET_EventLogID_PlaceHolder_Path); } if (!CHECK_if_File_Exists(Settings.GET_FilesToMonitor_Path)) { CREATE_NEW_Files_And_Dirs(Settings.Config_File_Location, Settings.FilesToMonitor_FileName, @"#C:\MyCustomApp\LogFile.log"); } if (!CHECK_if_File_Exists(Settings.GET_DirectoriesToMonitor_Path)) { CREATE_NEW_Files_And_Dirs(Settings.Config_File_Location, Settings.DirectoriesToMonitor_FileName, @"#%SystemDrive%\inetpub\logs\LogFiles"); } }
internal static string READ_AllText(string FilePath) { bool FIleExists = CHECK_if_File_Exists(FilePath); if (FIleExists && CHECK_File_Encrypted(FilePath)) { Crypto_Operation.UnSecure_File(FilePath); string Contents = File.ReadAllText(FilePath); Crypto_Operation.Secure_File(FilePath); return(Contents); } else { if (FIleExists == false) { Error_Operation.Log_Error("READ_AllText()", "File not found " + FilePath, "", Error_Operation.LogSeverity.Informataion); return(null); } else { return(File.ReadAllText(FilePath)); } } }