When Value is a quoted-string, quotation marks (") are removed automatically.
It means that, two following statement,
A.WriteString('Section','Key','"abcde"')
and
A.WriteString('Section','Key','abcde')
are not different.
Please see my code (it is quite clearly):
program project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes, IniFiles, sysutils
{ you can add units after this };
var
List: TIniFile;
A, B: String;
begin
List := TIniFile.Create('file.ini');
A := '"abcde"';
List.WriteString('Section', 'Key', A);
List.Free;
List := TIniFile.Create('file.ini');
B := List.ReadString('Section', 'Key', '');
List.Free;
if A<>B then raise Exception.Create(Format('A<>B (A=[%s] but B=[%s])', [A, B]));
end.
The previous code raise the following exception: A<>B (A=["abcde"] but B=[abcde])
I want to code something like this: A.WriteString('Section', 'Key', List.CommaText);
Because List.CommaText
may be a quoted-string, I have no solution to code as above.
Is it a bug or features? How can I save a TStrings
into a TIniFile
?