Ejemplo n.º 1
0
        // ------------------------------------------------ BORDER OF FUNCTION ---------------------------------------------------------- //
        public static void iniWrite(string path, string section, string key, string value)
        {
            bool readyToWrite = false;

            blockClearSR = true;
            string line = stringRead(path, section, key);

            if (lineIndex != -1)
            {
                if (value != null && value.Length == 0)
                {
                    value = null;
                }
                if (!string.Equals(line, value, StringComparison.OrdinalIgnoreCase))
                {
                    cacheFile[lineIndex] = key + "=" + value;
                    readyToWrite         = true;
                }
            }
            else
            {
                if (startIndex != -1 && enbIndex != -1)
                {
                    cacheFile[enbIndex] += Environment.NewLine + key + "=" + value;
                    readyToWrite         = true;
                }
                else if (File.Exists(path))
                {
                    FuncMisc.appendToFile(path, Environment.NewLine + "[" + section + "]" + Environment.NewLine + key + "=" + value);
                }
            }
            if (readyToWrite)
            {
                FuncMisc.writeToFile(path, cacheFile);
            }
            cacheFile.Clear();
        }