如何将一个或多个扩展名为*.log文件从C盘一个文件夹转移到D盘一个文件夹路径下面?时钟控件时时刻刻判断路径下面有没.log文件,当此文件存在时,即做一个“动作”后转移路径(什么动作就不劳烦大家了),不存在时,什么都不做。
如:C:\TEST\123.LOG
   D:\TEST\123.LOG小生试了很多方法,感觉都不是很满意,特来此请教各位大虾!谢谢

解决方案 »

  1.   

    有没有用api fileexists就可以了,
      

  2.   

    楼上这位老兄,判断文件是否存在,我知道怎么做,我想知道主要是CUT文件怎么操作。
    如果用COPY和KILL的话,那就要获取文件名,我想在不获取文件名的情况下,全部转移后缀名为.LOG的文件。
      

  3.   

    调用命令行两个命令:Copy 和 Del均支持通配符.
      

  4.   

    Private Sub Form_Load()
       Timer1.Interval = 1000
       Timer1.Enabled = True
    End SubPrivate Sub Timer1_Timer()
       If Dir("c:\test\*.log") <> "" Then
          Timer1.Enabled = False
          Shell "cmd /c move c:\test\*.log " & "c:\test2"
          Timer1.Enabled = True
       End If
    End Sub
      

  5.   

    '更正Private Sub Form_Load()
       Timer1.Interval = 100
       Timer1.Enabled = True
       If Dir("c:\test2", vbDirectory) = "" Then MkDir "c:\test2"
    End Sub
      

  6.   

    VB高级编程中,有shell hook,有对关于拷贝的控制
      

  7.   

    感觉还是SHELL MOVE实用,不知道有没甚么API可以实现此功能?
      

  8.   


    dim sPath as string
    dim dPath as string
    sPath="C:\*.log"
    dPath="D:\"
    Shell "cmd /c move" & sPath & dPath这样为甚么不可以啊?我调试不可以
    SHELL既然可以加通配符,那么可以加变量吗?如上所示!有谁知道?
    那么有甚么方法可以实现路径也是变量来转移文件
      

  9.   

    Shell "cmd /c move " & sPath & " " & dPath 
      

  10.   

    今天试了一下楼上的"Shell "cmd /c move " & sPath & " " & dPath ",在一般情况情况下,是可以用的,但是存在一个问题:我调用一个路径选择对话框选择路径后:
    当路径为如:"C:\NEWFILE\"时可以转移文件;
    当路径为如:"C:\NEW FILE\"时不可以转移文件;
    即我发现SHELL命令后面的文件夹不可以有"空格",只要没有空格,可以实现文件转移,有空格则文件转移失败!问题:
    不知道是我的命令什么地方写错了,还是SHELL本来就只有这个功能?
      

  11.   

    'DOS是不支持长文件名中间带空格的,你试一下这个将路径转为短路径Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
    Private Sub Command1_Click()
       Shell "cmd /c move " & GetShortName(sPath) & " " & GetShortName(dPath)
    End SubPublic Function GetShortName(ByVal sLongFileName As String) As String
       Dim lRetVal&, sShortPathName$
       sShortPathName = Space(255)
       Call GetShortPathName(sLongFileName, sShortPathName, 255)
       GetShortName = Mid(sShortPathName, 1, InStr(sShortPathName, Chr(0)) - 1)
    End Function
      

  12.   

    Dim strFile As StringstrFile = Dir(C:\TEST\*.LOG)Do While strFile > ""
        Name "C:\TEST\" & strFile As "D:\TEST\" & strFile
        strFile = Dir()
    Loop
      

  13.   


    Shell "cmd /c move """ & sPath & """ """ & dPath & """"