一个简单问题 在线等待(50分)

  • 主题发起人 主题发起人 xljm1025
  • 开始时间 开始时间
X

xljm1025

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button2Click(Sender: TObject);
var
i:integer;
filename:string;
begin
for i:=0 to filelistbox1.Items.Count -1 do
begin
filename:=filelistbox1.Items.Strings;
if extractfileext(filename)='.dfm' then
‘文本文件转换为二进制文件,批量转换并保存。写不下去了 请指点 谢谢。’
 
定义内存文件变量,然后打开并读入文本文件,再SaveToFile到二进制文件,就可以了啊
 
在循环中调用下面的函数
procedure DfmTxt2Bin(ADfmFileName: string);
Var
inFileStream: TMemoryStream;
outFileStream: TFileStream;
begin
inFileStream := TMemoryStream.Create;
inFileStream.LoadFromFile(ADfmFileName);
try
outFileStream := TFileStream.Create(ADfmFileName, fmCreate);
try
try
inFileStream.Seek(0, soFromBeginning);
ObjectTextToBinary(inFileStream, outFileStream);
except
Raise Exception.Create(‘error on trans txt to bin.');
end;
finally
outFileStream.Free;
end;
finally
inFileStream.Free;
end;
end;
 
可不可以说具体一点 呀 大哥 还是不太明白

有没有源代码呀
 
我已经试过Flamboyant大哥的方法了 好像不行呀 转换出来的和以前根本不一样了
 
应该是把delphi6以后的dfm转换为兼容delphi5的dfm吧
 
好像问题被改过了阿,以前不是text转binary么,
用来将binary类型的dfm文件转为文本类型的dfm文件
procedure DfmBin2Txt(ADfmFileName: string);
Var
inFileStream: TMemoryStream;
outFileStream: TFileStream;
begin
inFileStream := TMemoryStream.Create;
inFileStream.LoadFromFile(ADfmFileName);
try
outFileStream := TFileStream.Create(ADfmFileName, fmCreate);
try
try
inFileStream.Seek(0, soFromBeginning);
ObjectResourceToText(inFileStream, outFileStream);
except
Raise Exception.Create('This dfm is bin, error on trans bin to txt.');
end;
finally
outFileStream.Free;
end;
finally
inFileStream.Free;
end;
end;
ObjectTextToResource用来将文本类型的dfm文件转为binary类型的dfm文件
 
很感谢FLAMBOYANT 大哥 是我问错了问题 不过分还还是给你
 
后退
顶部