Delphi快速从文件流读取数据存入本地
var:
fs:TFileStream;
Path:string;
Buf4:array[0…3] of byte;
Str:string;
begin
fs := TFileStream.Create(Path+’*.map’, fmOpenRead or fmShareExclusive);
with fs do
begin
position:=0;
read(Buf4,4);
Str:=inttostr(Buf4[0]);
end;
fs.free;
with TStringList.Create do try
Add(Str);
SaveToFile(‘c:\temp.txt’);
finally
Free;
end;
end;
本文介绍使用Delphi从文件流中读取数据并将其转换为字符串的方法。通过创建TFileStream实例,设置路径和读取模式,可以定位到文件的起始位置,并读取指定数量的字节。读取的数据被存储在一个字节数组中,然后转换为字符串。最后,将字符串添加到TStringList中并保存到本地文件。
1316

被折叠的 条评论
为什么被折叠?



