拷贝文件时,如果目的文件存在,则要弹出一个文件替换的对话框,请问文件替换的API是什么?

解决方案 »

  1.   

    The CopyFile function copies an existing file to a new file. BOOL CopyFile(    LPCTSTR lpExistingFileName, // pointer to name of an existing file 
        LPCTSTR lpNewFileName, // pointer to filename to copy to 
        BOOL bFailIfExists  // flag for operation if file exists 
       );
     ParameterslpExistingFileNamePoints to a null-terminated string that specifies the name of an existing file. lpNewFileNamePoints to a null-terminated string that specifies the name of the new file. bFailIfExistsSpecifies how this operation is to proceed if a file of the same name as that specified by lpNewFileName already exists. If this parameter is TRUE and the new file already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds.  Return ValuesIf the function succeeds, the return value is nonzero.
    If the function fails, the return value is zero. To get extended error information, call GetLastError.
      

  2.   

    if fileexists(sFileName) then
       if  MessageDlg('文件'+sFileName+'已经存在是否替换?', mtConfirmation, [mbYes, mbNo], 0)=mrYes 
       then
       begin
          CopyFile(...);
        .....
       end;
      

  3.   

    我要的是文件替换的api,象windows那样的,不知道有没有
      

  4.   

    CopyFile 函数有一个参数表示是否覆盖的。
      

  5.   

    SHFileOperation可以在目的文件存在,弹出一个文件替换的对话框