admin管理员组文章数量:1317906
I'm trying to make a program the saves value to ini file. Already imported Salaros.configparser, declare path with string and try to save some value after some dropdowm value with yes and no.
I follow this youtube tutorial:
Res.choice is a dropdown for screen resolution
private void btn_save_Click(object sender, EventArgs e)
{
var setup_ini = new ConfigParser(setupini);
if (this.Res_choice.Text == "1920x1080")
{
setup_ini.SetValue("TEST", "Value1", "Yes");
}
else
{
setup_ini.SetValue("TEST", "Value1", "No");
}
}
Tried this and get error:
"Salaros.Configuration.ConfigParserException: 'This key value pair is orphan, all the keys must be preceded by a section.. On the line no. #2.'"
At first, I thought it was because the program can't find the header so I added it to the ini file and it still show the same error.
[TEST]
Value1=Yes
I'm trying to make a program the saves value to ini file. Already imported Salaros.configparser, declare path with string and try to save some value after some dropdowm value with yes and no.
I follow this youtube tutorial: https://www.youtube/watch?v=c7C54GlAvdI
Res.choice is a dropdown for screen resolution
private void btn_save_Click(object sender, EventArgs e)
{
var setup_ini = new ConfigParser(setupini);
if (this.Res_choice.Text == "1920x1080")
{
setup_ini.SetValue("TEST", "Value1", "Yes");
}
else
{
setup_ini.SetValue("TEST", "Value1", "No");
}
}
Tried this and get error:
"Salaros.Configuration.ConfigParserException: 'This key value pair is orphan, all the keys must be preceded by a section.. On the line no. #2.'"
At first, I thought it was because the program can't find the header so I added it to the ini file and it still show the same error.
[TEST]
Value1=Yes
Share
Improve this question
asked Feb 22 at 4:43
Pavaris PobhirunPavaris Pobhirun
11 bronze badge
1 Answer
Reset to default 0Mentioned error happens when there is no section header like below.
Value1=Yes
Stack trace:
Unhandled exception. Salaros.Configuration.ConfigParserException: This key value pair is orphan, all the keys must be preceded by a section.. On the line no. #1.
at Salaros.Configuration.ConfigParser.BackupCurrentLine(ConfigSection& currentSection, ConfigLine& currentLine, Int32 lineNumber)
at Salaros.Configuration.ConfigParser.Read(String configContent)
at Salaros.Configuration.ConfigParser..ctor(String configFile, ConfigParserSettings settings)
at Program.<Main>$(String[] args) in ...
Adding a section header must fix the exception. Please make sure to save the file after adding the section header.
本文标签:
版权声明:本文标题:c# - Received error Salaros.Configuration.ConfigParserException: 'This key value pair is orphan, ....." - Stack 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741350239a2373821.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论