Open MMWPF opened 7 years ago
Yep, I'm afraid that's a flaw in the library: it does not saves where the comments, or any other construct, for the matter, are located in relation with the rest of the file. In other words, this library does not takes into account the physical layout of elements on the file.
I'm very aware of the issue, and several people show concern about the problem, so it is something I want to solve for version 3.0. I'm getting holidays very soon and hopefully I can devote some time to work on in.
Sorry for the inconvenience
Sorry, missed your question about the wrapping spaces in key/value pairs, you can change the character to use as spacer at IniData.Configuration.AssigmentSpacer = '';
To MMWPF Guys,I think maybe we can use this to fix your problem. fileIniData.Parser.Configuration.CommentRegex = new Regex(@";[\s\S]*$"); The only regret is that the comment is above the key,but i think that would be okay than the problem.
I am reading an ini file, which contains inline comments. I am changing it a bit (Add keys, Update keys values...) and then save it. In the outup ini I have 2 major chnages:
Example file (Before) [Example] ABC=2 ;This is a very importend comment DEF=3 ;Yet, another very importend comment
Example file (After) [Example] ABC = 2 DEF = 3
Here is the code I am using: string exampleFilePath = "TBD add example file path here"; FileIniDataParser fileIniData = new FileIniDataParser(); fileIniData.Parser.Configuration.CommentRegex = new Regex(";(.)"); IniData exampleFileData= fileIniData.ReadFile(exampleFilePath); KeyDataCollection generalSection = exampleFileData.Sections["Example"]; / In this section I am changing things in the file */ fileIniData.WriteFile(exampleFilePath, exampleFileData);
Any ideas ?