以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]我的代码哪里出错了  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=69366)

--  作者:monvzhilei
--  发布时间:2015/6/3 20:11:00
--  [求助]我的代码哪里出错了

请教,我依样画葫芦的写了几句代码。在datacolchanging里面输入以下代码

 

 

   For Each dr As Row In CurrentTable.Rows
            Dim str1 As String =dr("头像照片")
            If FileSys.FileExists("F:\\小陶\\照片" & str1)  = True  Then
                dr("判断") = "找到"
            Else
               
                dr("判断") = Nothing
            End If
        Next

 

问题来了,没有任何反应,不知道出错在哪儿?

   


图片点击可在新窗口打开查看此主题相关图片如下:2015-06-03_200853.png
图片点击可在新窗口打开查看

--  作者:大红袍
--  发布时间:2015/6/3 20:14:00
--  

 代码没问题,合成的路径改一下,路径不能有错

 

FileSys.FileExists("F:\\小陶\\照片\\" & str1) 


--  作者:monvzhilei
--  发布时间:2015/6/3 20:30:00
--  

FileSys.FileExists("F:\\小陶\\照片\\" & str1) 

 

我即使修改为

FileSys.FileExists("F:\\小陶\\照片\\" & str1 & "") 也不行

我后来索性修改为:

 

 Dim lj As String = ProjectPath
        For Each dr As Row In CurrentTable.Rows
        Dim str1 As String =dr("头像照片")
            If FileSys.FileExists("" & lj & "Attachments\\" & str1 & "")  = True Then

                 dr("判断") = "找到"
            Else
               
                dr("判断") = Nothing
            End If
        Next

 

 

这样也不行。到底咋了啊。哎


--  作者:大红袍
--  发布时间:2015/6/3 20:32:00
--  
 你的文件放在哪个文件夹里?
--  作者:monvzhilei
--  发布时间:2015/6/3 20:36:00
--  

我实际放的是  F:\\小陶\\照片\\  这里

 

后来我想。即使attachments里面。不放任何文件,那么总有nothing输出的啊。  为什么都没有任何反应?


--  作者:大红袍
--  发布时间:2015/6/3 20:40:00
--  
 nothing 就是空白字符串啊,你可以改成 "不存在"
--  作者:monvzhilei
--  发布时间:2015/6/3 20:41:00
--  

我修改为:

 

 Dim lj As String = ProjectPath
        For Each dr As Row In CurrentTable.Rows
        Dim str1 As String =dr("头像照片")
            If FileSys.FileExists("" & lj & "Attachments\\" & str1 & "")  = True Then
                dr("判断") = "找到"
            Else
               
                dr("判断") = "找不到"
            End If
 Next

 

  这样也没有任何反应


--  作者:大红袍
--  发布时间:2015/6/3 20:45:00
--  

 那说明你的表没有数据

 

Dim lj As String = ProjectPath
For Each dr As DataRow In CurrentTable.DataTable.dataRows
    Dim str1 As String =dr("头像照片")
    If FileSys.FileExists(lj & "Attachments\\" & str1)  = True Then
        dr("判断") = "找到"
    Else
       
        dr("判断") = "找不到"
    End If
Next


--  作者:monvzhilei
--  发布时间:2015/6/3 20:47:00
--  

我的头像照片列有数据啊。我截图里面也很多的呢。

刚测试了,试用了您的代码。还是没有任何反应。 难道不应该写在datacolchanging里面?


--  作者:monvzhilei
--  发布时间:2015/6/3 20:50:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:2015-06-03_204930.png
图片点击可在新窗口打开查看