注册 登录
编程论坛 VB6论坛

求助:为何rmdir删除空文件夹会出错?

czb27111111 发布于 2015-04-02 21:23, 518 次点击
if dir(thepath,d......)<>"" then
kill thepath & "*"
rmdir thepath
end if
在rmdir那行提示75号错误
3 回复
#2
HVB62015-04-03 07:21
回复 楼主 czb27111111
试试:
'判断目录是否存在,存在就删除目录中的所有文件及目录本身
If Dir(thepath, vbDirectory) <> "" Then
If Dir(thepath & "\*.*") <> "" Then
Kill thepath & "\*.*"    '没有子目录
End If
End If
If Dir(thepath, vbDirectory) <> "" Then
If Dir(thepath & "\*.*") = "" Then
RmDir thepath '文件删除完成后,再删除文件夹
End If
End If

[ 本帖最后由 HVB6 于 2015-4-3 07:23 编辑 ]
#3
czb271111112015-04-03 17:29
回复 2楼 HVB6
解决了

    If Dir(ThePath & "*") <> "" Then
        Kill ThePath & "*"
    End If
    If Dir(ThePath & "*") = "" Then
        RmDir ThePath
    End If

应该是删除的间隔太短了吧

[ 本帖最后由 czb27111111 于 2015-4-3 17:31 编辑 ]
1