首先声明 调用api '判断输入参数是否为文件或文件夹 Private Declare Function PathFileExists Lib "shlwapi.dll" Alias "PathFileExistsA" (ByVal pszPath As String) As Long 然后找文件 if PathFileExists(txtFileName) = False Then '文件不存在 if GetAttr(txtFileName) = vbDirectory then '输入是文件夹删除文件 kill(txtFileName) 时间控制:timer,注意需要转化成秒来计算
Private Sub Timer1_Timer() On Error Resume Next Kill PathName End End SubTimer1.Interval = 300000
'判断输入参数是否为文件或文件夹
Private Declare Function PathFileExists Lib "shlwapi.dll" Alias "PathFileExistsA" (ByVal pszPath As String) As Long
然后找文件
if PathFileExists(txtFileName) = False Then '文件不存在
if GetAttr(txtFileName) = vbDirectory then '输入是文件夹删除文件 kill(txtFileName)
时间控制:timer,注意需要转化成秒来计算
On Error Resume Next
Kill PathName
End
End SubTimer1.Interval = 300000