///<summary> /// Append to a file if entity not allready present. ///</summary> ///<param name="fileName"> /// The filename to be used in format: [filename].[extention]. ///</param> ///<param name="savePath"> /// The folder to save in. /// If not setted, the file will be saved in "pSavepath". ///</param> public string FileAccumulate(string fileName = "", string savePath = "") { if (!Initial("FileAccumulate()")) { return(null); } try { if (fileName == "") { fileName = FileName; } if (savePath == "") { savePath = pSavepath + fileName; } else { if (savePath[savePath.Length - 1] != '\\') { savePath += '\\'; } savePath += fileName; } if (Validators.ValidateWriteAccess(savePath) == false) { Fault("You don't have write access!"); return(savePath); } object obj = GetS(); if (obj is string == false && obj is string[] == false && obj is IEnumerable <object> == false) { Fault("Invalid value!"); return(savePath); } if (obj is string) { string str = obj as string; IO.Accumulate(savePath, str); Success(fileName + " -> " + str.Length.ToString() + " chars of data processed!"); return(savePath); } else if (obj is string[]) { string str = String.Join(Environment.NewLine, obj as string[]); IO.Accumulate(savePath, str); Success(fileName + " -> " + (obj as string[]).Count().ToString() + " lines processed!"); return(savePath); } Fault("Invalid value!"); return(null); } catch (Exception ex) { Exceptional(ex); return(null); } }
///<summary> /// Append to a file if entity not allready present. ///</summary> ///<param name="s"> /// The string to be appended. ///</param> ///<param name="fileName"> /// The filename to be used in format: [filename].[extention]. ///</param> ///<param name="savePath"> /// The folder to save in. /// If not setted, the file will be saved in "pSavepath". ///</param> public string FileAccumulate(string s, string fileName, string savePath = "") { if (!Initial("FileAccumulate()")) { return(null); } try { if (fileName == "") { fileName = FileName; } if (savePath == "") { savePath = pSavepath + fileName; } else { if (savePath[savePath.Length - 1] != '\\') { savePath += '\\'; } savePath += fileName; } if (Validators.ValidateWriteAccess(savePath) == false) { Fault("You don't have write access!"); return(savePath); } IO.Accumulate(savePath, s); Success(fileName + " -> " + s.Length.ToString() + " chars of data processed!"); return(savePath); } catch (Exception ex) { Exceptional(ex); return(null); } }