A
amer
Unregistered / Unconfirmed
GUEST, unregistred user!
Function TForm1.AddToFile(SourceFile,TargetFile:String):Boolean;
var
Source,Target:TFileStream;
FileSize:integer;
begin
try
Source:=TFileStream.Create(SourceFile,fmOpenRead or fmShareExclusive );
Target:=TFileStream.Create(TargetFile,fmOpenWrite or fmShareExclusive);
try
Target.Seek(0,sofromend);//往尾部添加资源
Target.CopyFrom(Source,0);
Filesize:=Source.Size+ sizeof(SourceFile);
Target.WriteBuffer(FileSize, Sizeof(FileSize));
finally
Target.Free;
Source.Free;
end;
except
Result:=False;
Exit;
end;
Result:=True;
showmessage('写入成功!');
end;
--------------------------------------------------------------------------------
为什么Filesize:=Source.Size+ sizeof(SourceFile);里的sizeof(sourcefile)总是4呢?
还有如果source.size是文件的大小了,那sizeof(sourefile)是什么东西啊,
代表什么意思???谢谢了,,请帮我!!!!!!!
var
Source,Target:TFileStream;
FileSize:integer;
begin
try
Source:=TFileStream.Create(SourceFile,fmOpenRead or fmShareExclusive );
Target:=TFileStream.Create(TargetFile,fmOpenWrite or fmShareExclusive);
try
Target.Seek(0,sofromend);//往尾部添加资源
Target.CopyFrom(Source,0);
Filesize:=Source.Size+ sizeof(SourceFile);
Target.WriteBuffer(FileSize, Sizeof(FileSize));
finally
Target.Free;
Source.Free;
end;
except
Result:=False;
Exit;
end;
Result:=True;
showmessage('写入成功!');
end;
--------------------------------------------------------------------------------
为什么Filesize:=Source.Size+ sizeof(SourceFile);里的sizeof(sourcefile)总是4呢?
还有如果source.size是文件的大小了,那sizeof(sourefile)是什么东西啊,
代表什么意思???谢谢了,,请帮我!!!!!!!