以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  ‘想判断不等于formid的数据 就删除,结果数据全部删除了’  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=183335)

--  作者:cnsjroom
--  发布时间:2022/11/1 15:34:00
--  ‘想判断不等于formid的数据 就删除,结果数据全部删除了’

‘想判断不等于formid的数据  就删除,结果数据全部删除了’

怎么修正呢?等于formid的值的数据不删除  反之就删除

 

当前代码如下:
Dim cmd As New SQ LCommand
cmd.Conn ectio nName = "web"
cmd.Comma ndText =  "sel ect * from {Navigation}"
Dim bt As DataTable = cmd.ExecuteReader()
Dim Products As List(Of String)
Products = bt.GetValues("formid")

For Each Product As String In Products
    For Each File As String In FileSys.GetFiles(ProjectPath & "MyWeb\\pages\\")
       
        If file.Contains(Product) Then   ‘想判断不等于formid的数据  就删除,结果数据全部删除了’
        Else
            If FileSys.FileExists(File) Then \'如果指定的文件存在
                output.show(File)
                FileSys.DeleteFile(File,2,2) \'则彻底删除之
            End If
        End If
    Next
Next

[此贴子已经被作者于2022/11/1 15:34:53编辑过]

--  作者:有点蓝
--  发布时间:2022/11/1 16:09:00
--  
调换代码的顺序
    For Each File As String In FileSys.GetFiles(ProjectPath & "MyWeb\\pages\\")
For Each Product As String In Products

--  作者:cnsjroom
--  发布时间:2022/11/1 17:46:00
--  回复:(有点蓝)调换代码的顺序    F...

Dim cmd As New S QLCommand
cmd.Conn ecti
cmd.Comm andText =  "sele ct * from {Navigation}"
Dim bt As DataTable = cm d.ExecuteReader()
Dim Products As List(Of String)
Products = bt.GetValues("formid")
For Each File As String In FileSys.GetFiles(ProjectPath & "MyWeb\\pages\\")
For Each Product As String In Products
        If file.Contains(Product) Then   \'想判断不等于formid的数据  就删除,结果数据全部删除了\'
        Else

            If FileSys.FileExists(File) Then \'如果指定的文件存在
                output.show(File)
                FileSys.DeleteFile(File,2,2) \'则彻底删除之
            End If

        End If
    Next
Next

 

老师调换顺序后  还是一样  全部干掉了 


--  作者:有点蓝
--  发布时间:2022/11/1 19:54:00
--  
For Each File As String In FileSys.GetFiles(ProjectPath & "MyWeb\\pages\\")
    Dim k As Boolean
    For Each Product As String In Products
        If file.Contains(Product) Then \'想判断不等于formid的数据  就删除,结果数据全部删除了\'
            k = True
            Exit For
        End If
    Next
    If k = False Then 
        output.show(File)
        FileSys.DeleteFile(File, 2, 2) \'则彻底删除之
    End If
Next