TFileStream对象的创建
简述
创建类TfileStream的实例对象
CreateObject(‘TFileStream’;Alias;FileName;FileMode)
名称 | 类型 | 说明 |
---|
Alias | String | 字符串类型,目录别名。 |
FileName | String | 字符串类型,文件名。 |
FileMode | integer | 整数类型。为打开模式和共享模式的组合值(相加)。打开模式:共享模式:取值 | 说明 | 0 | FCBs打开模式共享 | 16 | 禁止共享打开 | 32 | 禁止写共享 | 48 | 禁止读共享 | 64 | 允许读写共享 |
|
范例:
FileName:="E:\\Test\\TFileCase01.txt";
//-新建一个txt文件并打开
obj:= CreateObject("TFileStream","",FileName,65535);
buffer:="ABC 123";
p:= obj.write(buffer,7); //写入
//-读取
b:="";
SetLength(b,7);
obj.Position:=0; //必须设置起始位置,否则失败
obj.Read(b,7);
return b;
返回字符串:ABC 123