看你小子太小气了,一分都不给,不过做个好人,下次大方点...
procedure TForm1.Button1Click(Sender: TObject);
var
F : TextFile;
Str : string;
FileName : string;
begin
AssignFile(F,FileName);
if FileExists(FileName) then
Append(F)
else
ReWrite(F);
WriteLn(Str);
CloseFile(F);
end;
procedure MyAddStr(MyStr:string);
implementation
procedure MyAddStr(MyStr:string);
Var
MothodFile:TextFile;
FileName:String;
FileOpened:Boolean;
i,j:Integer;
Str1:array[0..100] of string;
str4:string;
Begin
i:=0;
FileName:=ExtractFilePath(Application.Exename)+'log.txt';
AssignFile(MothodFile,FileName);
Try
Reset(MothodFile);
FileOpened:=True;
Except
On EInOutError Do
Begin
Try
if FileExists(FileName)=False then
Begin
ReWrite(MothodFile);
FileOpened:=True;
End
Else
Begin
FileOpened:=False;
ShowMessage('文件不能打开');
End;
Except
On EInOutError Do
Begin
FileOpened:=False;
ShowMessage('文件不能创建');
End;
End;
End;
End;
if fileopened=false then exit;
While not eof(MothodFile) and (i<99) do
Begin
Readln(MothodFile,Str4);
Str1[i]:=trim(str4);
inc(i);
end;
CloseFile(MothodFile);
AssignFile(MothodFile,FileName);
ReWrite(MothodFile);
Writeln(MothodFile,mystr+' At:'+datetimetostr(now));
for j:=0 to i do
Begin
str4:=Str1[j];
Writeln(MothodFile,str4);
End;
CloseFile(MothodFile);