以文本方式查看主题

-  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=120904)

--  作者:OKK
--  发布时间:2018/6/26 9:16:00
--  [求助]判断图片是否存在
Dim fl As String = "d:\\web\\" & e.path
If
 filesys.FileExists(fl)
    Dim idx As Integer = fl.LastIndexOf(".")
    Dim ext As String  = fl.SubString(idx)
    Select Case ext
        Case ".jpg",".gif",".png",".bmp",".wmf",".js",".css" ,".html",".htm",".zip",".rar"
            e.WriteFile(fl)
            Return \'
这里必须返回
    End Select

End
 If
Select
 Case e.Path
    Case "test.htm"
        Dim wb As new WeUI
        With wb.AddGallery("","gla1")
            .AddImage("./images/001.jpg","./images/002.jpg","./images/003.jpg","./images/004.jpg")
        
End With
        e.WriteString(wb.Build) \'生成网页
End
 
Select



http://www.foxtable.com/mobilehelp/scr/0087.htm



以上案例,如果路径中的图片不存在时,会提示出错
我想先判断图片名称是否在路径中,如果存在则显示图片,如果不存在则不显示
请问怎么写?

--  作者:有点甜
--  发布时间:2018/6/26 9:30:00
--  
我测试这段代码,并没有报错。没有的图片,显示是空白的黑色背景。
--  作者:有点甜
--  发布时间:2018/6/26 9:36:00
--  

判断是否存在,参考代码

 

Select Case e.Path
    Case "test.htm", ""
        Dim wb As new WeUI
        With wb.AddGallery("","gla1")
            Dim ary()As String = {"/images/001hkjh.jpg","/images/jhk002.jpg","/images/001.jpg","/images/jhj004.jpg"}
            Dim str As String = "c:\\web"
            For Each s As String In ary
                If filesys.FileExists(str & s)
                    .AddImage(s)
                End If
            Next
        End With
        e.WriteString(wb.Build) \'生成网页
End Select


--  作者:OKK
--  发布时间:2018/6/26 10:20:00
--  
好,谢谢图片点击可在新窗口打开查看