delphi 如何把任意类型的文件以16进制读取出来?
1个回答
展开全部
下面的程序是将文件读出以16进制写进文本文件var
sfile:file;
dfile:Textfile;
byteread,i:integer;
buffer:array
of
byte;begin
if
opendialog1.Execute
then
assignfile(sfile,opendialog1.FileName)
else
abort;
if
savedialog1.Execute
then
assignfile(dfile,savedialog1.FileName)
else
abort;
try
reset(sfile,1);
rewrite(dfile);
repeat
blockread(sfile,buffer,sizeof(buffer),byteread);
if
byteread>0
then
begin
for
i1
to
byteread
do
begin
write(dfile,format('%0.2x',
));
write(dfile,'
');
end;
writeln(dfile,'');
end;
until
byteread=0;
finally
closefile(sfile);
closefile(dfile);
end;
sfile:file;
dfile:Textfile;
byteread,i:integer;
buffer:array
of
byte;begin
if
opendialog1.Execute
then
assignfile(sfile,opendialog1.FileName)
else
abort;
if
savedialog1.Execute
then
assignfile(dfile,savedialog1.FileName)
else
abort;
try
reset(sfile,1);
rewrite(dfile);
repeat
blockread(sfile,buffer,sizeof(buffer),byteread);
if
byteread>0
then
begin
for
i1
to
byteread
do
begin
write(dfile,format('%0.2x',
));
write(dfile,'
');
end;
writeln(dfile,'');
end;
until
byteread=0;
finally
closefile(sfile);
closefile(dfile);
end;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询