procedure WriteFile;
const
LEN = 100;
var
fs: TStream;
Str: array [0..LEN-1] of Char;
begin
StrCopy(Str, 'This is a example of the program.');
fs := TFileStream.Create('c:/dd.dat', fmCreate);
try
fs.Write(Str, LEN);
finally
fs.Free;
end;
end;
大概是这样吧。
var
F: file of Char;
begin
Assign(F, FileName);
{$I-} Rewrite(F)
{$I+}
if IOResult <> 0 then begin
WriteLn('Can not open the file!');
Halt(1);
end;
Write(F, 'd大西洋df');
Close(F);
end;