AddLogLine() public static method

Adds a single line
public static AddLogLine ( string sLine ) : void
sLine string Line to add
return void
Example #1
0
        /// <summary>
        /// Reads the specified ini file
        /// </summary>
        /// <param name="sFile">The file to read from</param>
        /// <param name="cSplitItem">The character to split on</param>
        /// <returns>Dictionary of keys and values read from the file</returns>
        private Dictionary <string, string> GetIniTable(string sFile, char cSplitItem)
        {
            var dictionaryItems = new Dictionary <string, string>();

            try
            {
                if (File.Exists(sFile))
                {
                    var arrayLines = File.ReadAllLines(sFile);
                    foreach (var sLine in arrayLines)
                    {
                        var arraySplit = sLine.Split(new char[] { cSplitItem }, 2);
                        var sItem      = m_bMatchCase ? arraySplit[0] : arraySplit[0].ToLower();
                        if (!dictionaryItems.ContainsKey(sItem))
                        {
                            dictionaryItems.Add(sItem, arraySplit[1]);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logger.AddLogLine("Failed to get settings: " + e);
            }
            return(dictionaryItems);
        }
Example #2
0
        /// <summary>
        /// Flushes the Ini settings to the file associated with this object
        /// </summary>
        public void FlushIniSettings()
        {
            string sDirectory = Path.GetDirectoryName(Filename);

            if (sDirectory != null && !Directory.Exists(sDirectory))
            {
                Directory.CreateDirectory(sDirectory);
            }

            try
            {
                var zWriter = new StreamWriter(Filename, false);

                foreach (var sKey in m_dictionaryItems.Keys)
                {
                    zWriter.WriteLine(sKey + CHAR_SPLITTER + m_dictionaryItems[sKey]);
                }
                zWriter.Close();
            }
            catch (Exception e)
            {
                Logger.AddLogLine("Failed to persist settings: " + e);
            }
        }