如何用VB达到把一个文件从C:拷到D:
Private Sub Command1_Click()
exec xp_cmdshell 'copy c:\program files\我的音乐 d:\我的音乐'
End Sub
出错:子程序或函数未定义,为什么?

解决方案 »

  1.   

    Dim objFile As New FileSystemObject    objfile.CopyFile "c:\工资数据表.dbf", "d:\工资数据表.dbf", True
      

  2.   

    不行,出错“用户定义类型未定义”
    Private Sub Command1_Click()
    exec xp_cmdshell 'copy c:\program files\我的音乐 d:\我的音乐'
    End Sub
    上面“EXEC”是什么,如何使用?
      

  3.   

    Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As LongPrivate Sub Command1_Click()
       CopyFile "c:\test.txt","d:\new.txt",1
    End Sub
      

  4.   

    不行,出错“用户定义类型未定义”
    ------------------------------------------
    引用“Microsoft Scripting Runtime”