Beispiel #1
0
        private void MapStringFromIni(string inipath, bool selfmodify = false) //必须要新建了inilist_sw才能用。selfmodify是在规范化文件的时候不直接操作原文件而是复制一个临时文件进行操作。
        {
            ini_file  aa  = new ini_file(inipath, selfmodify);
            ArrayList tmp = aa.ReadSections();

            for (int i = 0; i < tmp.Count; i++)
            {
                string section = ((string)tmp[i]);
                //ArrayList tmp2 = aa.ReadKeys(section);    //无法读取"号

                ArrayList tmp2       = aa.GetIniSectionValue(section);
                ArrayList repetition = new ArrayList();

                for (int j = 0; j < tmp2.Count; j++)
                {
                    string KeynValue = ((string)tmp2[j]).Trim();
                    //MessageBox.Show((string)tmp2[tmp2.Count-1]);
                    int divider = KeynValue.IndexOf("=");
                    if (divider == -1 || KeynValue.IndexOf("//") == 0)
                    {
                        continue;
                    }                                                                   //其他杂七杂八的数据
                    string key   = KeynValue.Substring(0, divider).Trim();
                    string value = KeynValue.Substring(key.Length + 1, KeynValue.Length - key.Length - 1).Trim();
                    if (HasChinese(value))
                    {
                        //MessageBox.Show(value);
                        string replacement = "INI_STRING " + pos.ToString();
                        if (value[0] == '"' && value[value.Length - 1] == '"')
                        {
                            replacement = '"' + replacement + '"';
                            value       = value.Substring(1, value.Length - 2);
                        }
                        //发现上面有key跟当前key重复
                        if (repetition.Contains(key))
                        {   //独立函数
                            aa.WriteIniKeys_Indp(section, key, replacement, value);
                        }
                        else
                        {
                            aa.WriteIniKey(section, key, replacement);
                        }
                        inilist_sw.WriteLine(pos.ToString() + " | " + value);
                        pos = pos + 1;
                    }
                    repetition.Add(key);
                }
            }
        }
Beispiel #2
0
        //必须要新建了inilist_sw才能用。selfmodify是在规范化文件的时候不直接操作原文件而是复制一个临时文件进行操作。
        private void MapStringFromIni(string inipath, bool selfmodify = false)
        {
            ini_file aa = new ini_file(inipath, selfmodify);
            ArrayList tmp = aa.ReadSections();
            for (int i = 0; i < tmp.Count; i++)
            {
                string section = ((string)tmp[i]);
                //ArrayList tmp2 = aa.ReadKeys(section);    //无法读取"号

                ArrayList tmp2 = aa.GetIniSectionValue(section);
                ArrayList repetition = new ArrayList();

                for (int j = 0; j < tmp2.Count; j++)
                {
                    string KeynValue = ((string)tmp2[j]).Trim();
                    //MessageBox.Show((string)tmp2[tmp2.Count-1]);
                    int divider = KeynValue.IndexOf("=");
                    if (divider == -1 || KeynValue.IndexOf("//") == 0) { continue; }    //其他杂七杂八的数据
                    string key = KeynValue.Substring(0, divider).Trim();
                    string value = KeynValue.Substring(key.Length + 1, KeynValue.Length - key.Length - 1).Trim();
                    if (HasChinese(value))
                    {
                        //MessageBox.Show(value);
                        string replacement = "INI_STRING " + pos.ToString();
                        if (value[0] == '"' && value[value.Length - 1] == '"')
                        {
                            replacement = '"' + replacement + '"';
                            value = value.Substring(1, value.Length - 2);
                        }
                        //发现上面有key跟当前key重复
                        if (repetition.Contains(key))
                        {   //独立函数
                            aa.WriteIniKeys_Indp(section, key, replacement, value);
                        }
                        else { aa.WriteIniKey(section, key, replacement); }
                        inilist_sw.WriteLine(pos.ToString() + " | " + value);
                        pos = pos + 1;
                    }
                    repetition.Add(key);
                }
            }
        }