delphi BlockRead和BlockWrite读写文件


本文整理自网络,侵删。

 
var   
 FromF, ToF: file;   
 NumRead, NumWritten: Integer;   
 Buf: array[1..2048] of Char;   
begin   
 if OpenDialog1.Execute then begin   
   AssignFile(FromF, OpenDialog1.FileName);   
   Reset(FromF, 1); { Record size = 1 }   
   if SaveDialog1.Execute then { Display Save dialog box}   
   begin   
     AssignFile(ToF, SaveDialog1.FileName); { Open output file }   
     Rewrite(ToF, 1); { Record size = 1 }   
     Canvas.TextOut(10, 10, 'Copying ' + IntToStr(FileSize(FromF))   
+ ' bytes...');   
     repeat   
       BlockRead(FromF, Buf, SizeOf(Buf), NumRead);   
       BlockWrite(ToF, Buf, NumRead, NumWritten);   
    until (NumRead = 0) or (NumWritten <> NumRead);   
    CloseFile(FromF);   
    CloseFile(ToF);   
  end;   
end;   
end;  

相关阅读 >>

Delphi 为数字补充前缀0

Delphi windows 编程[15] - 菜单消息: wm_command

Delphi mscomm控件串口收发程序

Delphi操作access

Delphi键盘按键伪码多类型

Delphi源码获取网络图片缓存的地址

Delphi datasnap 2009的简单使用

Delphi ��b以 listbox 的item �� hint

Delphi android检查互联网连接

Delphi strtohexstr 字符串转换hex

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...

    暂无评论...