关于一个复制硬盘一个分区的问题(100分)

  • 主题发起人 主题发起人 sl220
  • 开始时间 开始时间
S

sl220

Unregistered / Unconfirmed
GUEST, unregistred user!
请教一下各位,我用了一个拷贝目录函数,函数如下:<br>&nbsp;sCurDir:=GetCurrentDir;<br>&nbsp; &nbsp; ChDir(sDirName);<br>&nbsp; &nbsp; hFindFile:=FindFirstfile('*.*',FindFileData);<br>&nbsp; &nbsp; if hFindFile&lt;&gt;INVALID_HANDLE_VALUE &nbsp;then<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; if not DirectoryExists(sToDirName) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ForceDirectories(sToDirName); <br>&nbsp; &nbsp; &nbsp; &nbsp; repeat<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tfile:=FindFileData.cFileName; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (tfile='.') or (tfile='..')then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Continue;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (FindFileData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) =FILE_ATTRIBUTE_DIRECTORY then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t:=sToDirName+'/'+tfile;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if not DirectoryExists(t) then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ForceDirectories(t); <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if sDirName[Length(sDirName)]&lt;&gt;'/' then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DoCopyDir(sDirName+'/'+tfile,t);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Attrs:=FileGetAttr(sDirName+'/'+tfile);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FileSetAttr(t,Attrs);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DoCopyDir(sDirName+tfile,sToDirName+tfile);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Attrs:=FileGetAttr(sDirName+tfile);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FileSetAttr(t,Attrs);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; t:=sToDirName+'/'+tFile;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CopyFile(PChar(tfile),PChar(t),True);<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; &nbsp; until FindNextFile(hFindFile,FindFileData)=false;<br>&nbsp; &nbsp; &nbsp; end<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; ChDir(sCurDir);<br>&nbsp; &nbsp; &nbsp; &nbsp; result:=false;<br>&nbsp; &nbsp; &nbsp; &nbsp; exit;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; //回到原来的目录下<br>&nbsp; ChDir(sCurDir);<br>&nbsp; result:=true;<br>&nbsp; end;<br>我的目的是把整个硬盘的文件拷贝到一个文件夹中,例如把C:/考被到d:/win98,但是发现一个问题,用了这个函数,如果拷贝分区上的某个文件夹没有任何问题,但是如果拷贝整个分区就不可以,程序会出错,希望高手能够指点一下,谢谢~~
 
晕!你想让别人帮你试,也得把函数帖完整啊,你这不是浪费别人的时间么?
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
740
import
I
I
回复
0
查看
571
import
I
I
回复
0
查看
779
import
I
后退
顶部