function GetFileSize(const AFileName:string):Integer;
var
f: file of Byte;
begin
AssignFile(f, AFileName);
Reset(f);
try
try
Result := FileSize(f);
except
Result := -1;
end;
finally
CloseFile(f);
end;
end;
{改写已存在的文件中的内容,2005-03-19}
function FillDataToFile(const AFileName:string;
const Buff;
WriteCount:Integer;
Position:Integer):integer;
var
FileHandle : Integer;
begin
FileHandle := 0;
try
FileHandle := FileOpen(AFileName, fmOpenWrite or fmShareDenyNone);
FileSeek(FileHandle,Position,0);
Result := FileWrite(FileHandle,Buff,WriteCount);
except
Result := -1;
end;
FileClose(FileHandle);
end;
{建立一个指定大小的空文件}
procedure CreateEmptyFile(const AFileName:string;FileSize:Integer);
var
FS:TFileStream;
begin
if FileSize < 0 then FileSize := 0;
FS := TFileStream.Create(AFileName,fmCreate);
FS.Size := FileSize;
FS.Free();
end;