Example #1
0
        public IniFile(string fileName)
        {
            if (!System.IO.File.Exists(fileName))
                throw new System.IO.FileNotFoundException("File " + fileName + " Not found");

            byte[] buffer = new byte[32767];
            int i = 0;
            string[] sTmp, kTmp;

            i = GetPrivateProfileString(null, null, null, buffer, 32767, fileName);
            if (i == 0)
            {
                sections = new Section[0];
                return;
            }

            sTmp = System.Text.Encoding.GetEncoding(1252).GetString(buffer, 0, i).TrimEnd((char)0).Split((char)0);
            sections = new Section[sTmp.Length];
            for( int j = 0; j< sTmp.Length ; j++)
            {
                i = GetPrivateProfileString(sTmp[j], null, null, buffer, 32767, fileName);
                kTmp = System.Text.Encoding.GetEncoding(1252).GetString(buffer, 0, i).TrimEnd((char)0).Split((char)0);
                Key[] keys = new Key[kTmp.Length];
                for( int k =0; k< kTmp.Length ; k++)
                {
                    i = GetPrivateProfileString(sTmp[j], kTmp[k], null, buffer, 32767, fileName);
                    keys[k] = new Key( kTmp[k] , System.Text.Encoding.GetEncoding(1252).GetString(buffer, 0, i).TrimEnd((char)0));
                }
                sections[j] = new Section(sTmp[j], keys);
            }
        }
Example #2
0
 public Section( string sectionName,  Key[] keys)
 {
     this.keys = keys;
     name = sectionName;
 }