以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  删除FTP对应路径的附件  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=122132)

--  作者:cd_tdh
--  发布时间:2018/7/19 14:55:00
--  删除FTP对应路径的附件

老师,添加附件代码如下,我删除行怎么删除对应行路径的附件呢?

        Dim dlg As New openFileDialog \'定义一个新的SaveFileDialog
        dlg.MultiSelect = True
        If dlg.showDialog = DialogResult.Ok Then \'如果用户单击了确定按钮
            Dim ftp1 As new  ftpclient
            ftp1.host="000.00.000.0"
            ftp1.Account = "******"
            ftp1.password = "*******"
            Dim r As Row = Tables("人员证件").Current
            Dim ls = r.DataRow.Lines("证件缩略图")
            For Each f As String In dlg.FileNames
                Dim file = "/人员证件/" & r("姓名") & "/" & filesys.GetName(f)
                If ftp1.DirExists("/人员证件/" & r("姓名")) = False Then
                    ftp1.MakeDir("/人员证件/" & r("姓名"))
                End If
                Dim Result As DialogResult
                If ftp1.FileExists(file) Then
                    Result = MessageBox.Show("文件已经存在,是否覆盖?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                End If
                If result = Nothing OrElse result = DialogResult.Yes Then
                    If  ftp1.Upload(f,file,True) = True Then
                        If ls.contains(file) = False Then
                            ls.add(file)
                        End If
                    Else
                        MessageBox.Show( f & "上传失败" ,"提示" ,MessageBoxButtons.OK,MessageBoxIcon.Question)
                    End If
                End If
            Next
            r.DataRow.lines("证件缩略图") = ls
            ftp1.Close
        End If


--  作者:有点甜
--  发布时间:2018/7/19 15:48:00
--  

datarowdeleting事件,循环每一个文件删除,如

 

Dim dr As DataRow = e.DataRow
Dim ls As List(of String) = dr.lines("证件缩略图")
Dim ftp1 As new  ftpclient
ftp1.host="000.00.000.0"
ftp1.Account = "******"
ftp1.password = "*******"
For Each s As String In ls
    ftp1.DeleteFile(s)
Next
ftp1.close