比如a盘有一些文件 ,现在在编辑框中输入某一文件的名字,按‘确定’按扭,就把该文件从a盘复制到c盘,用什么命令?谢谢
  我用下面这个语句,但是文件名只能是file.txt啊!55555555555
      CopyFile('a:\file.txt','c:\file.txt', True);

解决方案 »

  1.   

    ShellAPI的SHFileOperation
    网上的例子太多了
      

  2.   

    function CopyFileTo(const Source: string; const Destination: string): Boolean;Parametersconst Source: stringSource file name.
    const Destination: stringDestination file name.
    ReturnsBoolean - True if the file is copied, False on error.
    DescriptionCopyFileTo is a function used to copy the file specified in Source to the file specified in Destination.
    CopyFileTo will return False if the file in Destination already exists.
    CopyFileTo encapsulates the platform-specific calls needed to perform the file copy operation. On the Windows platform, this is the Win32 API function CopyFile. On the Linux platform, CopyFileTo uses a TFileStream instance to create the destination file.
      

  3.   

    program del;
    uses ShellApi;
    { 利用ShellApi中: function SHFileOperation(const lpFileOp: TSHFileOpStruct): Integer; stdcall; }
    Var T:TSHFileOpStruct;
    P:String;
    begin
    P:='C:\Windows\System\EL_CONTROL.CPL';
    With T do
    Begin
    Wnd:=0;
    wFunc:=FO_copy;
    pFrom:=Pchar(P);
    fFlags:=FOF_ALLOWUNDO
    End;
    SHFileOperation(T);
    End.
      

  4.   

    CopyFile('a:\file.*','c:\file.*', True);