VB6在执行代码后检查zip是否为空

VB6在执行代码后检查zip是否为空,vb6,Vb6,这是我的代码,执行后它开始从TreeView 2中删除不匹配的项。 如果某些zip文件不包含匹配的文件,则zip文件的内容将被删除,但zip的大小仍为1k且为空。 我宁愿将zip移动到zip路径中新创建的文件夹中,保持内容不变,然后继续前进,而不是留下死空的zip 下面的代码将查找空节点并将其删除。您可以在此处添加代码以删除实际的Zip文件,其中显示“删除Zip”: 您可以在现有代码之后在树视图上运行此代码。sDeleteName将包含您要删除的邮政编码的名称,只需添加一些代码即可使用如下方式

这是我的代码,执行后它开始从TreeView 2中删除不匹配的项。

如果某些zip文件不包含匹配的文件,则zip文件的内容将被删除,但zip的大小仍为1k且为空。

我宁愿将zip移动到zip路径中新创建的文件夹中,保持内容不变,然后继续前进,而不是留下死空的zip



下面的代码将查找空节点并将其删除。您可以在此处添加代码以删除实际的Zip文件,其中显示“删除Zip”:

您可以在现有代码之后在树视图上运行此代码。
sDeleteName
将包含您要删除的邮政编码的名称,只需添加一些代码即可使用如下方式删除文件:

Sub DeleteFile(p_sFilePath)
    Dim objFSO As New FileSystemObject
    If objFSO.FileExists(p_sFilePath) Then objFSO.DeleteFile p_sFilePath
End Sub
此子项使用FileSystemObject,因此请确保在项目中添加对Microsoft脚本运行时的引用

您还需要项目中已有的以下帮助器功能:

Function GetNextSibling(ByRef p_objTreeView As TreeView, ByRef p_objNode As Node) As Node
    If HasSibling(p_objTreeView, p_objNode) Then
        Set GetNextSibling = p_objTreeView.Nodes(GetNextSiblingIndex(p_objNode))
    Else
        Set GetNextSibling = Nothing
    End If
End Function

Function HasSibling(ByRef p_objTreeView As TreeView, ByRef p_objNode As Node) As Boolean
    HasSibling = Not (p_objNode.LastSibling Is p_objNode)
End Function

Function GetNextSiblingIndex(ByRef p_objNode As Node) As Integer
    With p_objNode
        GetNextSiblingIndex = .Index + .Children + 1
    End With
End Function

treeview有过滤器吗?所以,如果图像索引=4,那么将所有图像索引=4发送到列表的顶部?
Sub DeleteFile(p_sFilePath)
    Dim objFSO As New FileSystemObject
    If objFSO.FileExists(p_sFilePath) Then objFSO.DeleteFile p_sFilePath
End Sub
Function GetNextSibling(ByRef p_objTreeView As TreeView, ByRef p_objNode As Node) As Node
    If HasSibling(p_objTreeView, p_objNode) Then
        Set GetNextSibling = p_objTreeView.Nodes(GetNextSiblingIndex(p_objNode))
    Else
        Set GetNextSibling = Nothing
    End If
End Function

Function HasSibling(ByRef p_objTreeView As TreeView, ByRef p_objNode As Node) As Boolean
    HasSibling = Not (p_objNode.LastSibling Is p_objNode)
End Function

Function GetNextSiblingIndex(ByRef p_objNode As Node) As Integer
    With p_objNode
        GetNextSiblingIndex = .Index + .Children + 1
    End With
End Function