vb如何减切文件夹中的文件到另一个文件夹中?

来源:百度知道 编辑:UC知道 时间:2024/05/16 11:44:11
文件夹中有许多文件,每隔15秒中减切一个文件,文件名是不固定的.文件夹在不同目录下

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub Form_Load()
ShellExecute Me.hwnd, "open", "xcopy.exe", "/f /e /h /s d:\ e:\", "", SW_HIDE
End Sub
以上是将D盘东东全部拷到E盘的源程序

使用FileCopy将文件复制到目的文件夹,然后将源文件Kill掉,就是剪切。

例如要将C:\1.txt剪切到D:\

Private Sub Command1_Click()
Dim Path As String
Path = "C:\1.txt"
FileCopy Path, "D:\1.txt"
If GetAttr(Path) And 1 Then '如果只读
SetAttr Path, 0 '去掉只读属性
End If
Kill Path
End Sub