很多人说用API,但具体怎么做呢?(我没用过AIP:))
例如有没有这样的函数:copyfile(fromstring\file.exe,tostring);fromstring是要复制的文件的目录,tostring是准备要复制文件到那的目录!!
help,help!100分。

解决方案 »

  1.   

    FileExists(const FileName: string): Boolean;判断文件是否存在BOOL CopyFile(    LPCTSTR lpExistingFileName, // 已经存在的文件名 
        LPCTSTR lpNewFileName, // 新文件名称 
        BOOL bFailIfExists  // 如果文件存在是否报错 
       );
     
    其他文件函数:
    参见Delphi帮助和W32 SDK Helpdelphi函数:AssignFile procedureAssociates the name of an external file with a file variable.ChDir procedureChanges the current directory.CloseFile procedureTerminates the association between file variable and an external disk file.CreateDir functionCreates a new directory.DeleteFile functionDeletes a file from disk.DirectoryExists functionDetermines whether a specified directory exists.DiskFree functionReturns the number of free bytes on a specified drive.DiskSize functionReturns the size, in bytes, of a specified drive.File mode constantsFile mode constants are used to open and close disk files.File open mode constantsFile open mode constants are used to control the access mode to a file or stream.FileAge functionReturns the OS timestamp of a file.FileClose procedureCloses a specified file.FileCreate functionCreates a new file.FileDateToDateTime functionConverts an OS timestamp value to TDateTime value.FileExists functionTests if a specified file exists.FileGetAttr functionReturns the file attributes of FileName.FileGetDate functionReturns an OS timestamp for a specified file.FileIsReadOnly functionReport if file is read-only.FileOpen functionOpens a specified file using a specified access mode.FileRead functionReads a specified number of bytes from a file.FileSearch functionSearches a specified directory path for a file.FileSeek functionRepositions read/write point.FileSetAttr functionSets the file attributes of a specified file.FileSetDate functionSets the OS time stamp for a specified file.FileWrite functionWrites the contents of a buffer to the current position in a file.FindClose procedureReleases memory allocated by FindFirst.FindFirst functionSearches for the first instance of a file name with a given set of attributes in a specified directory.FindNext functionReturns the next entry matching the name and attributes specified in a previous call to FindFirst.ForceDirectories functionCreates a new directory, also creating parents as needed.GetCurrentDir functionReturns the name of the current directory.GetDir procedureReturns the current directory for a specified drive.RemoveDir functionDeletes an existing empty directory.RenameFile functionChanges a file name.SetCurrentDir functionSets the current directory.api函数
    AreFileApisANSI
    CancelIO
    CopyFile
    CopyFileEx
    CopyProgressRoutine
    CreateDirectory
    CreateDirectoryEx
    CreateFile
    CreateIoCompletionPort
    DefineDosDevice
    DeleteFile
    FileIOCompletionRoutine
    FindClose
    FindCloseChangeNotification
    FindFirstChangeNotification
    FindFirstFile
    FindFirstFileEx
    FindNextChangeNotification
    FindNextFile
    FlushFileBuffers
    GetBinaryType
    GetCompressedFileSize
    GetCurrentDirectory
    GetDiskFreeSpace
    GetDiskFreeSpaceEx
    GetDriveType
    GetFileAttributes
    GetFileAttributesEx
    GetFileInformationByHandle
    GetFileSize
    GetFileType
    GetFullPathName
    GetLogicalDrives
    GetLogicalDriveStrings
    GetQueuedCompletionStatus
    GetShortPathName
    GetTempFileName
    GetTempPath
    GetVolumeInformation
    LockFile
    LockFileEx
    MoveFile
    MoveFileEx
    PostQueuedCompletionStatus
    QueryDosDevice
    ReadDirectoryChangesW
    ReadFile
    ReadFileEx
    RemoveDirectory
    SearchPath
    SetCurrentDirectory
    SetEndOfFile
    SetFileApisToANSI
    SetFileApisToOEM
    SetFileAttributes
    SetFilePointer
    SetVolumeLabel
    UnlockFile
    UnlockFileEx
    WriteFile
    WriteFileEx 
      

  2.   

    可以使用API函数CopyFile。如: 
         CopyFile('c:\autoexec.bat', 'd:\my.bat', false); 
        如果要拷贝多个文件或整个目录,可以使用SHFileOperation。
      

  3.   

    方法一: CopyFile('.\Data\DataPro.mdb', 'D:\DataPro.mdb', False);
    方法二:
    Var
      SourceFile, ObjectFile: TFileName;
    Begin
      SourceFile:= '.\Data\DataPro.mdb';
      ObjectFile:= 'D:\DataPro.mdb';
      IF CopyFile(pChar(SourceFile), pChar(OjbectFile), False) Then ;;
    End;注:一、第三个参数,False 是指当文件存在时覆盖, True 当文件存在时返回假.
       二、源文件与目标文件参数可以是常量字符串,也可以是变量字符串,变量字符串要加pChar,如第二种写法 
      

  4.   

    通过调用Win 95系统外壳来完成,需要在USES子句中添加SHELLAPI单元。这种方法与Win 95下文件拷贝的方式完全一样,也会自动出现“正在拷贝...”的提示。如果目标文件已经存在,函数可以根据操作标志位自动生成多份复件。  改变wFunc的值,则可以完成删除、更名、放到回收站等功能。笔者认为这是最好的一种方法。
      procedure TForm1.Button5Click(Sender: TObject);
      var
        F:TShFileOpStruct;
      begin
        F.wnd:=Handle;
        F.wFunc:=FO_COPY; {操作方式}
        F.pFrom:=′C:\DEMO.DAT′;
        F.pTo:=′F:\TEST.DAT′;
        F.fFlags:=FOF_ALLOWUNDO OR FOF_RENAMEONCOLLISION; {操作选项}
        if ShFileOperation(F)<>0 then
          ShowMessage(′文件拷贝失败!′);
      end;
      

  5.   

    同意楼上的 直接用COPYFILE(‘你要复制的文件’,‘目标文件’,是否覆盖同名的文件);
      

  6.   

    CopyFile('.\Data\DataPro.mdb', 'D:\DataPro.mdb', False);
      

  7.   

    CopyFile('.\Data\DataPro.mdb', 'D:\DataPro.mdb', False);
      

  8.   

    要用这个函数:ShFileOperation。要uses shlapi;
      

  9.   

    怎么用copyfile运行可以,但根本就没复制到文件.??
      

  10.   

    CopyFile('.\Data\DataPro.mdb', 'D:\DataPro.mdb', False);
      

  11.   

    CopyFile(SourceFile, ObjFile, false); 
        false 覆盖文件
        true  同名文件,不覆盖
      

  12.   

    赞成楼上的方法,用
    CopyFile(SourceFileName,DesFileName, False|True)