API
BOOL CopyFile(
  LPCTSTR lpExistingFileName, // name of an existing file
  LPCTSTR lpNewFileName,      // name of new file
  BOOL bFailIfExists          // operation if file exists
);

解决方案 »

  1.   

    一个窗口,再加上一个按钮,然后写一下语句
    msgbox("请使用windows自身的复制文件功能")
      

  2.   

    to: enmity(灵感之源) 
    当然是指运行最快to:jjx() 
    msgbox("我要用VB编写") 
      

  3.   

    声明:
    Declare Function CopyFile Lib ""kernel32"" Alias ""CopyFileA"" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
      

  4.   

    VB声明 
    Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long 
    说明 
    复制文件。与vb的filecopy命令相似 
    返回值 
    Long,非零表示成功,零表示失败。会设置GetLastError 
    参数表 
    参数 类型及说明 
    lpExistingFileName String,源文件名 
    lpNewFileName String,目标文件名 
    bFailIfExists Long,如果设为TRUE(非零),那么一旦目标文件已经存在,则函数调用会失败。否则目标文件被改写 
      

  5.   

    或者使用SHFileOperation API,功能更加强大
    声明:
    Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
    Private Const FO_COPY = &H2
    Private Const FO_DELETE = &H3
    Private Const FO_RENAME = &H4
    Private Const FOF_ALLOWUNDO = &H40Public Function CopyFile(sFrom As String, sTo As String)
        '** Description:
        '** Copy file
        On Error GoTo CopyError
        Dim SHFO As SHFILEOPSTRUCT
        With SHFO
            .wFunc = FO_COPY 'Set copy metod
            .pFrom = sFrom 'Set from filename
            .pTo = sTo 'Set to filename
        End With
        SHFileOperation SHFO 'Copy file
        exit functionCopyError:
        msgbox err.description
    End Function上面的程序没有调试过,你自己测试一下吧 :)
      

  6.   

    呵呵,我来补充一下拉掉的SHFILEOPSTRUCTPrivate Type SHFILEOPSTRUCT
            hWnd As Long
            wFunc As Long
            pFrom As String
            pTo As String
            fFlags As Integer
            fAnyOperationsAborted As Long
            hNameMappings As Long
            lpszProgressTitle As String '  only used if FOF_SIMPLEPROGRESS
    End Type
      

  7.   

    整个代码如下:Private Type SHFILEOPSTRUCT
            hWnd As Long
            wFunc As Long
            pFrom As String
            pTo As String
            fFlags As Integer
            fAnyOperationsAborted As Long
            hNameMappings As Long
            lpszProgressTitle As String '  only used if FOF_SIMPLEPROGRESS
    End TypePrivate Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
    Private Const FO_COPY = &H2
    Private Const FO_DELETE = &H3
    Private Const FO_RENAME = &H4
    Private Const FOF_ALLOWUNDO = &H40Public Function CopyFile(sFrom As String, sTo As String)
        '** Description:
        '** Copy file
        On Error GoTo CopyError
        Dim SHFO As SHFILEOPSTRUCT
        With SHFO
            .wFunc = FO_COPY 'Set copy metod
            .pFrom = sFrom 'Set from filename
            .pTo = sTo 'Set to filename
        End With
        SHFileOperation SHFO 'Copy file
      exit functionCopyError:
        msgbox err.descriptionEnd Function