public static bool WritePrivateProfileSection( string appName, string value, string fileName) { using (var inifile = new MLangInifile(fileName)) { return(inifile.WritePrivateProfileSection(appName, value)); } }
static void InstanceTest(string fileName) { Console.WriteLine(@"----------------------------------------------"); Console.WriteLine(Path.GetFileName(fileName)); Console.WriteLine(@"----------------------------------------------"); using (var inifile = new MLangInifile(fileName)) { var builder = new StringBuilder(1024); inifile.GetPrivateProfileString("Encoding", "Lang", string.Empty, builder, builder.Capacity); int count = inifile.GetPrivateProfileInt("Write", "Count", 0); Console.WriteLine("Encodings={0} Lang={1} count={2}", inifile.CharacterSet, builder, count); count++; inifile.WritePrivateProfileString("Write", "Count", count.ToString()); string buffer = string.Format("WritePrivateProfileSectionのテスト{0}", count); inifile.WritePrivateProfileSection("Section", buffer); inifile.GetPrivateProfileSection("Section", builder, builder.Capacity); Console.WriteLine(builder.ToString()); } }
static void StaticTest(string fileName) { Console.WriteLine(@"----------------------------------------------"); Console.WriteLine(Path.GetFileName(fileName)); Console.WriteLine(@"----------------------------------------------"); var builder = new StringBuilder(1024); MLangInifile.GetPrivateProfileString("Encoding", "Lang", string.Empty, builder, builder.Capacity, fileName); int count = MLangInifile.GetPrivateProfileInt("Write", "Count", 0, fileName); Console.WriteLine("Lang={0} count={1}", builder, count); count++; MLangInifile.WritePrivateProfileString("Write", "Count", count.ToString(), fileName); string buffer = string.Format("WritePrivateProfileSectionのテスト{0}", count); MLangInifile.WritePrivateProfileSection("Section", buffer, fileName); MLangInifile.GetPrivateProfileSection("Section", builder, builder.Capacity, fileName); Console.WriteLine(builder.ToString()); }