Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to using config-parser without sections? #25

Open
byBenPuls opened this issue Feb 22, 2024 · 0 comments
Open

How to using config-parser without sections? #25

byBenPuls opened this issue Feb 22, 2024 · 0 comments

Comments

@byBenPuls
Copy link

Hello, dear developer.
My .cfg file does not contain sections (like [section]). How i can using libary?
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 Salaros.Configuration.ConfigParser.BackupCurrentLine(ConfigSection& currentSection, ConfigLine& currentLine, Int32 lineNumber)
   at Salaros.Configuration.ConfigParser.ReadKeyAndValue(ConfigSection& currentSection, ConfigLine& currentLine, String lineRaw, Int32 lineNumber, Boolean append, Boolean forceIncludeKey)
   at Salaros.Configuration.ConfigParser.Read(String configContent)
   at Salaros.Configuration.ConfigParser..ctor(String configFile, ConfigParserSettings settings)
   at Launcher_CS.Form1.Form1_Load(Object sender, EventArgs e) in line 43
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Control.CreateControl(Boolean ignoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(HWND hWnd, MessageId msg, WPARAM wparam, LPARAM lparam)

Code:

            var configFileFromPath = new ConfigParser(@"config.cfg",
                new ConfigParserSettings
                {
                    KeyValueSeparator = " ",
                    MultiLineValues = MultiLineValues.QuoteDelimitedValues
                    
                });
            
            string CsName = configFileFromPath.GetValue(null, "name"); // Error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant