以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  求怎样删除c 盘web文件夹的".jpg",".gif",".png",".bmp",".wmf",".txt"文件,谢谢  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=100621)

--  作者:limit_1982
--  发布时间:2017/5/15 13:20:00
--  求怎样删除c 盘web文件夹的".jpg",".gif",".png",".bmp",".wmf",".txt"文件,谢谢
Dim fl As String = "c:\\web\\"
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",".txt" \'
            filesys.DeleteFile(fl,2,2)
    End Select
End If
[此贴子已经被作者于2017/5/15 13:33:21编辑过]

--  作者:有点色
--  发布时间:2017/5/15 14:31:00
--  
Dim fl As String = "g:\\web\\"
For Each file As String In FileSys.GetFiles(fl)
    Dim idx As Integer = file.LastIndexOf(".")
    Dim ext As String  = file.SubString(idx)
    Select Case ext
        Case ".jpg",".gif",".png",".bmp",".wmf",".txt" \'
            filesys.DeleteFile(file,2,2)
    End Select
Next