Copyfileprogressbar (Pwidechar (Listbox1.items.strings[i]), Pwidechar (newdir+'\'+Extractfilename (Listbox1.items.strings[i])); procedureCopyfileprogressbar (Getpath,setpath:string);varGetstream,setstream:tfilestream; Num, N:integer; Buf:pbyte; Bufsize,block:integer;begin if notFileExists (GetPath) Then begin //showmessage (' source file does not exist '); //Exit; End; GetStream:= TFileStream.Create(GetPath, Fmopenreadorfmshareexclusive); SetStream:= TFileStream.Create(SetPath, fmcreate); Num:=getstream.size; Setstream.size:=num; Getstream.position:=0; Setstream.position:=0; BufSize:=num; Block:= BufSizeDiv -; Getmem (buf, BufSize); Form1. Progressbar1.max:= -; Form1. Progressbar1.min:=0; Form1. Progressbar1.position:=0; whileNum <>0 Do beginapplication.processmessages; N:=Block; ifn > num ThenN: =num; Getstream.readbuffer (buf^, N); Setstream.writebuffer (buf^, N); Form1. Progressbar1.position:= Trunc ((1-num/bufsize) * -); DEC (num, n); End; Freemem (buf, BufSize); Getstream.free; Setstream.free; //showmessage (' copy complete ');Form1. Progressbar1.position:=0;End;
Delphi Copyfileprogressbar Copy file display progress bar