为什么为什么??????(0分)

  • 主题发起人 主题发起人 royal666
  • 开始时间 开始时间
R

royal666

Unregistered / Unconfirmed
GUEST, unregistred user!
为什么我用以下的语句进行:先判断文件是否存在,若存在则先删除后拷贝,总是说删除的源文件不存在呢<br>&nbsp;With OpStruct do<br>&nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; Wnd := Handle;<br>&nbsp; &nbsp; &nbsp; &nbsp; WFunc := fo_delete;<br>&nbsp; &nbsp; &nbsp; &nbsp; pFrom := pchar(RepDest);<br>&nbsp; &nbsp; &nbsp; &nbsp; fFlags := fof_noconfirmation;<br>&nbsp; &nbsp; &nbsp; &nbsp; fanyoperationsaborted := False;<br>&nbsp; &nbsp; &nbsp; &nbsp; hnamemappings := nil;<br>&nbsp; &nbsp; &nbsp; &nbsp; lpszprogresstitle := nil;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; SHFileOperation(OpStruct);<br>&nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; With OpStruct do<br>&nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; Wnd := Handle;<br>&nbsp; &nbsp; &nbsp; &nbsp; WFunc := fo_copy;<br>&nbsp; &nbsp; &nbsp; &nbsp; pFrom := @FromBuf;<br>&nbsp; &nbsp; &nbsp; &nbsp; pTo := @ToBuf;<br>&nbsp; &nbsp; &nbsp; &nbsp; fFlags := fof_noconfirmation;<br>&nbsp; &nbsp; &nbsp; &nbsp; fanyoperationsaborted := False;<br>&nbsp; &nbsp; &nbsp; &nbsp; hnamemappings := nil;<br>&nbsp; &nbsp; &nbsp; &nbsp; lpszprogresstitle := nil;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; SHFileOperation(OpStruct); <br>&nbsp; &nbsp; end;
 
为什么会有错误呢?<br>function TFrmMain.CopyDir(SrcDir, ToDir: String): Boolean;<br>var<br>&nbsp; FromBuf, ToBuf : Array[0..128] of Char;<br>&nbsp; opstruct : TShfileopstruct;<br>&nbsp; RepDest : String;<br>&nbsp; FreeSpaceOnDest, SizeOfSource : LongWord;<br>begin<br>&nbsp; FillChar(FromBuf,sizeof(FromBuf),0);<br>&nbsp; FillChar(ToBuf,sizeof(ToBuf),0);<br>&nbsp; Strpcopy(FromBuf,ParamStr(1));<br>&nbsp; Strpcopy(ToBuf,ParamStr(2));<br>&nbsp; FreeSpaceOnDest := FreeSpace(ParamStr(2));<br>&nbsp; SizeOfSource := GetDirectorySize(ParamStr(1));<br>&nbsp; /// <br>&nbsp; Label3.Caption := IntToStr(FreeSpaceOnDest);<br>&nbsp; Label4.Caption := IntToStr(SizeOfSource);<br>&nbsp; /////////////////////////////////////<br>&nbsp; if FreeSpaceOnDest &lt; SizeOfSource then Erreur('Pas assez d''espace sur le disque Destination.');<br>&nbsp; RepDest := ParamStr(2) + '/' + ExtractFileName(ParamStr(1));<br>&nbsp; if not DirectoryExists(RepDest) then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; With OpStruct do<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; Wnd := Handle;<br>&nbsp; &nbsp; &nbsp; WFunc := fo_copy;<br>&nbsp; &nbsp; &nbsp; pFrom := @FromBuf;<br>&nbsp; &nbsp; &nbsp; pTo := @ToBuf;<br>&nbsp; &nbsp; &nbsp; fFlags := fof_noconfirmation;<br>&nbsp; &nbsp; &nbsp; fanyoperationsaborted := False;<br>&nbsp; &nbsp; &nbsp; hnamemappings := nil;<br>&nbsp; &nbsp; &nbsp; lpszprogresstitle := nil;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; SHFileOperation(OpStruct);<br>&nbsp; &nbsp; end<br>&nbsp; else<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; if MessageDlg('文件已存在,覆盖?',mtWarning,[mbYes,mbNo],0) = mrNo then<br>&nbsp; &nbsp; &nbsp; &nbsp; exit;<br><br>&nbsp; &nbsp; &nbsp; With OpStruct do<br>&nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; Wnd := Handle;<br>&nbsp; &nbsp; &nbsp; &nbsp; WFunc := fo_delete;<br>&nbsp; &nbsp; &nbsp; &nbsp; pFrom := pchar(RepDest);<br>&nbsp; &nbsp; &nbsp; &nbsp; fFlags := fof_noconfirmation;<br>&nbsp; &nbsp; &nbsp; &nbsp; fanyoperationsaborted := False;<br>&nbsp; &nbsp; &nbsp; &nbsp; hnamemappings := nil;<br>&nbsp; &nbsp; &nbsp; &nbsp; lpszprogresstitle := nil;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; SHFileOperation(OpStruct);<br>&nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; With OpStruct do<br>&nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; Wnd := Handle;<br>&nbsp; &nbsp; &nbsp; &nbsp; WFunc := fo_copy;<br>&nbsp; &nbsp; &nbsp; &nbsp; pFrom := @FromBuf;<br>&nbsp; &nbsp; &nbsp; &nbsp; pTo := @ToBuf;<br>&nbsp; &nbsp; &nbsp; &nbsp; fFlags := fof_noconfirmation;<br>&nbsp; &nbsp; &nbsp; &nbsp; fanyoperationsaborted := False;<br>&nbsp; &nbsp; &nbsp; &nbsp; hnamemappings := nil;<br>&nbsp; &nbsp; &nbsp; &nbsp; lpszprogresstitle := nil;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; SHFileOperation(OpStruct); <br>&nbsp; &nbsp; end;<br>end;
 
后退
顶部