private bool Load_File(string path) { Ini ini = new Ini(path); ClearLoad(); try { Load_file.http.Method = ini.ReadValue("HTTP", "Method"); Load_file.http.URL = ini.ReadValue("HTTP", "URL"); Load_file.http.version = ini.ReadValue("HTTP", "Version"); //Load_file.Config.Used = Convert.ToBoolean(ini.ReadValue("Config", "Used")); //Load_file.Config.proxyip = ini.ReadValue("Config", "Proxy"); //Load_file.Config.Request = Encoding.GetEncoding(ini.ReadValue("Config", "RequestEncoding")); //Load_file.Config.Response = Encoding.GetEncoding(ini.ReadValue("Config", "ResponseEncoding")); //Load_file.Login.Type = ini.ReadValue("Login", "Type"); //Load_file.Login.Used = Convert.ToBoolean(ini.ReadValue("Login", "Used")); //Load_file.Login.Server = Convert.ToInt32(ini.ReadValue("Login", "Server")); //Load_file.Login.Userid = ini.ReadValue("Login", "Userid"); //Load_file.Login.Password = ini.ReadValue("Login", "Password"); key.md5 = ini.ReadValue("KEY", "MD5"); key.AES = ini.ReadValue("KEY", "AES"); key.AuthAES = ini.ReadValue("KEY", "AuthAES"); string[] loadstrings = default_col; Load_file.Param.url_count = Convert.ToInt32(ini.ReadValue("Param_url", "Count")); for (int i = 0; i < Load_file.Param.url_count; i++) { for (int j = 0; j < loadstrings.Length; j++) { Load_file.Param.url[i, j] = ini.ReadValue("Param_url", loadstrings[j] + i.ToString()); } } Load_file.Param.body_count = Convert.ToInt32(ini.ReadValue("Param_body", "Count")); for (int i = 0; i < Load_file.Param.body_count; i++) { for (int j = 0; j < loadstrings.Length; j++) { Load_file.Param.body[i, j] = ini.ReadValue("Param_body", loadstrings[j] + i.ToString()); } } Load_file.Param.header_count = Convert.ToInt32(ini.ReadValue("Param_header", "Count")); for (int i = 0; i < Load_file.Param.header_count; i++) { for (int j = 0; j < loadstrings.Length; j++) { Load_file.Param.header[i, j] = ini.ReadValue("Param_header", loadstrings[j] + i.ToString()); } } //Param_Type = "Param_url"; return true; } catch (Exception e) { MessageBox.Show(path + "\r\n读取失败\r\n" + e.Message + "\r\n" + e.StackTrace); return false; } }
static void Mainini(string[] args) { string Current; Current = Directory.GetCurrentDirectory();//获取当前根目录 Console.WriteLine("Current directory {0}", Current); // 写入ini Ini ini = new Ini(Current + "/config.ini"); ini.WriteValue("Setting", "key1", "hello word!"); ini.WriteValue("Setting", "key2", "hello ini!"); ini.WriteValue("SettingImg", "Path", "IMG.Path"); // 读取ini string stemp = ini.ReadValue("Setting", "key2"); Console.WriteLine(stemp); Console.ReadKey(); }