怎样拷贝一批文件(100分)

  • 主题发起人 主题发起人 cbdelphi
  • 开始时间 开始时间
C

cbdelphi

Unregistered / Unconfirmed
GUEST, unregistred user!
我想问一下,怎样能一下,拷贝一批文件<br>(或知道这个目录下所有的文件名)。<br>比如:一下拷贝一个目录下的所有文件。<br>可是用API涵数CopyFile一下只可以<br>拷贝一个文件。<br>我主要是想做一个备份系统,一下可以<br>备份一个目录下的文件。如果你有更好的<br>办法,如:可以把多个文件打成包,<br>做成一个备份文件就更好了,多谢了!
 
f-h-s:<br>发送失败。
 
//目录,后缀,列表<br>procedure GetFileFilterList(Root:String;Filter:String;FileList:TStringList);<br>var<br>&nbsp; sr: TSearchRec;<br>&nbsp; FileAttrs: Integer;<br>begin<br>&nbsp; FileAttrs:=faArchive;<br>&nbsp; FileList.Clear;<br><br>&nbsp; if FindFirst(Root+Filter, FileAttrs, sr) = 0 then<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; if (sr.Attr and FileAttrs) = sr.Attr then<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp;FileList.Append(Root+SR.Name);<br>&nbsp; &nbsp; &nbsp; &nbsp;while FindNext(sr) = 0 do<br>&nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (sr.Attr and FileAttrs) = sr.Attr then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FileList.Append(Root+SR.Name);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp;FindClose(sr);<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp;end;<br>end;
 
用压缩的办法吧,zip。
 
to &nbsp;cbdelphi :<br>&nbsp; &nbsp; 我帮你做好了~~~<br>&nbsp; &nbsp; 假设你原来的目录为 c:/tyn1 &nbsp; 你现在想备份到 c:/tyn2目录下<br>~~~~~~<br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br>&nbsp; FileOpStruct :TSHFileOpStruct;<br>&nbsp; Buf1 :array [0..127] of Char;<br>&nbsp; Buf2 :array [0..127] of Char;<br>&nbsp; Str1,Str2 :String;<br>begin<br>&nbsp; Str1 :='c:/tyn1';<br>&nbsp; Str2 :='c:/tyn2';<br>&nbsp; FillChar(Buf1,SizeOf(Buf1),0);<br>&nbsp; FillChar(Buf2,SizeOf(Buf2),0);<br>&nbsp; StrPCopy(Buf1,Str1);<br>&nbsp; StrPCopy(Buf2,Str2);<br>&nbsp; with FileOpStruct do<br>&nbsp; begin<br>&nbsp; &nbsp; Wnd :=Handle;<br>&nbsp; &nbsp; wFunc :=FO_COPY;<br>&nbsp; &nbsp; pFrom :=@Buf1;<br>&nbsp; &nbsp; pTo :=@Buf2;<br>&nbsp; &nbsp; fFlags :=FOF_SIMPLEPROGRESS;<br>&nbsp; &nbsp; fAnyOperationsAborted :=False;<br>&nbsp; &nbsp; hNameMappings :=nil;<br>&nbsp; &nbsp; lpszProgressTitle :='拷贝文件';<br>&nbsp; end;<br>&nbsp; SHFileOperation(FileOpStruct);<br>end;
 
当然不要忘记在 uses 部分加入 ShellAPI 单元~~~~~
 
怎样用用压缩的办法,压缩成ZIP文件?
 
怎样解压ZIP文件
 
调用DOS程序 :RAR.EXE 或 ARJ.EXE
 
用rar 可以压缩成一个文件,然后解压开来,<br>可以参看 rar的帮助,只需要rar.exe文件,rar -? 可以看rar的参数<br>你可以调用winexec,shellexecute &nbsp;等来进行
 
有一个bakup控件,完全可以满足你的要求
 
对:卷起千堆雪tyn的做法感兴趣研究
 
to iseek<br>&nbsp; up兄弟,能否将backup控件email me? &nbsp;f-h-s@163.com<br>先谢谢了
 
f-h-s<br>已经将backup控件发给你了。
 
to iseek兄:<br>&nbsp; 我怎么没有收到啊!!能不能再给我发一遍?谢谢、、、、
 
to quaker:你的信箱是否已经满了?我的信总被退回来<br>
 
to iseek:<br>兄弟,能否将backup控件也email me? &nbsp;yangzcsoft@163.net<br>先谢谢了
 
写个批处理不就行了
 
to iseek兄:<br>&nbsp; pengyi007@tellyes.com<br><br>&nbsp; 谢谢
 
后退
顶部