以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  多文件上传  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=131502)

--  作者:刘林
--  发布时间:2019/2/27 22:00:00
--  多文件上传
Dim ftp1 As New FtpClient
ftp1.Host=""
ftp1.Account = ""
ftp1.Password = ""
Dim dlg As New OpenFileDialog
dlg.Filter= "文件|*.zip;*.txt;"
dlg.MultiSelect = True
If dlg.ShowDialog = DialogResult.OK Then
    Dim ifo As new FileInfo(dlg.filename)
    If ftp1.Upload(dlg.filename,"\\shengji\\" & Ifo.name,True) = True Then
               Messagebox.show("上传成功","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    End If
End If

老师,我想打开多个文件并上传,这样不行,只上传了一个,请问怎样实现将打开的多个文件一并上传

--  作者:有点甜
--  发布时间:2019/2/27 23:12:00
--  
Dim ftp1 As New FtpClient
ftp1.Host=""
ftp1.Account = ""
ftp1.Password = ""
Dim dlg As New OpenFileDialog
dlg.Filter= "文件|*.zip;*.txt;"
dlg.MultiSelect = True
If dlg.ShowDialog = DialogResult.OK Then
    For Each file As String In dlg.FileNames
        Dim ifo As new FileInfo(file)
        If ftp1.Upload(file,"\\shengji\\" & Ifo.name,True) = True Then
            Messagebox.show("上传成功","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        End If
    Next
End If