// 覆盖式写,不存在会创建 function MyWriteFile(filename, str: string):boolean; var filev: TextFile; localfilepath,ss: string; begin localfilepath:=gstrAppPath + filename; try AssignFile(filev, localfilepath); ReWrite(filev); writeln(filev, str); CloseFile(filev); finally end; end;
// 追加形式 function MyAppendFile(filename, str: string):boolean; var filev: TextFile; localfilepath,ss: string; begin localfilepath:=gstrAppPath + filename; try if FileExists(localfilepath) then begin AssignFile(filev, localfilepath); append(filev); writeln(filev, str); CloseFile(filev); end else begin AssignFile(filev, localfilepath); ReWrite(filev); writeln(filev, str); CloseFile(filev); end; finally end; end;
读取 ini 文件:
1 2 3 4 5 6 7 8 9
var foo: String; sectionName: TStrings; myinifile: TIniFile;