コード例 #1
0
 /// <summary>
 /// Writes a change to an INI file
 /// </summary>
 /// <param name="Section">Section</param>
 /// <param name="Key">Key</param>
 /// <param name="Value">Value</param>
 public virtual void WriteToINI(string Section, string Key, string Value)
 {
     if (FileContents.Keys.Contains(Section))
     {
         if (FileContents[Section].Keys.Contains(Key))
         {
             FileContents[Section][Key] = Value;
         }
         else
         {
             FileContents[Section].Add(Key, Value);
         }
     }
     else
     {
         Dictionary <string, string> TempDictionary = new Dictionary <string, string>();
         TempDictionary.Add(Key, Value);
         FileContents.Add(Section, TempDictionary);
     }
     WriteFile();
 }
コード例 #2
0
ファイル: InputFile.cs プロジェクト: douggal/rope-intranet
        internal void ReadInputFile()
        {
            try
            {
                using (StreamReader sr = new StreamReader(FileName))
                {
                    int    i = 0;
                    String line;

                    while ((line = sr.ReadLine()) != null)
                    {
                        FileContents.Add(line);
                        i++;
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
            }
        }
コード例 #3
0
ファイル: GenerateHeader.cs プロジェクト: tstaples/3DGraphics
        // Create the pre-processor header guards
        void WriteHeaderGuard()
        {
            string headermacro = null;
            string format      = ConfigFile.Get().GetString("HeaderGuardFormat");

            // Check for a flag indicator
            if (format.Contains('<'))
            {
                int beg = format.IndexOf('<');
                int end = format.IndexOf('>');
                headermacro = format.Substring(0, beg);

                // Parse the flag
                string flag = format.Substring(beg + 1, end - beg - 1);
                if (flag.CompareTo("filename") == 0)
                {
                    // "file" = filename
                    headermacro = headermacro + OutputPath.ToUpper();
                }
                headermacro = headermacro + format.Substring(end + 1, format.Length - (end + 1));
            }
            else
            {
                // Default macro definition
                headermacro = "INCLUDED_" + OutputPath.ToUpper() + "_H";
            }

            string endif     = "#endif";
            string hguardIF  = "#ifndef " + headermacro;
            string hguardDEF = "#define " + headermacro;

            // Insert the header guard macro definitions at the beginning of the file
            FileContents.Insert(0, hguardIF);
            FileContents.Insert(1, hguardDEF + Format.endl);

            // Close the preprocessor definition at the end of the file
            NewLine();
            FileContents.Add(endif + " " + "//" + hguardIF);
        }