将文件内容读入到一个字符串中。文件内容为二进制得数据
function TMyCipher.LoadBuffer(strFile: string): string;
var
hFile: TFileStream;
begin
hFile := TFileStream.Create(strFile, fmOpenRead);
hFile.Read(Result, hFile.Size);
hFile.Free;
end;访问返回值时出现非法操作。为啥?
function TMyCipher.LoadBuffer(strFile: string): string;
var
hFile: TFileStream;
begin
hFile := TFileStream.Create(strFile, fmOpenRead);
hFile.Read(Result, hFile.Size);
hFile.Free;
end;访问返回值时出现非法操作。为啥?
SetLenth(Result, hFile.Size+1);
hFile.Read(Result, hFile.Size);
var
slTmp: TStrings;
begin
slTmp:= TStringList.Create;
slTmp.LoadFromFile(strFile);
result:= slTmp.Text;
slTmp.Free;
end;