rickyah / ini-parser

Read/Write an INI file the easy way!
MIT License
972 stars 241 forks source link

How ignoring special characters like hash # at reading or common? #243

Open Paderman opened 1 year ago

Paderman commented 1 year ago

How is it possible to ignore hash or other special characters at the beginning or common?

I have a non standard ini file that begins with a special character like # for comments, but with this character, I get an error message, without, it works.

Error message: IniParser.Exceptions.ParsingException: 'Unknown file format. Couldn't parse the line: '#'. while parsing line number 0 with value '' - IniParser version: 2.5.2.0 while parsing line number 1 with value '#' - IniParser version: 2.5.2.0'

Thank you for your solution and helping 🙂

jacobussystems commented 1 year ago

Well, you can use '#' for comments, e.g.

var parser = new FileIniDataParser();
parser.Parser.Configuration.CommentString = "#";

(That setting defaults to ';', by the way.)

Hope that helps, Jim