以文本方式查看主题

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

--  作者:shenhq
--  发布时间:2014/6/2 21:46:00
--  [求助]这个ftp代码有问题!

Dim dlg As New OpenFileDialog
dlg.MultiSelect = True
dlg.Filter= "图片文件|*.jpg|图片文件|*.jpeg" \'设置筛选器
If dlg.ShowDialog = DialogResult.OK Then
    Dim  ftp1 As  New  FtpClient
    ftp1.Host="220.223.220.220"
    ftp1.Account =  "ftpuser"
    ftp1.Password =  "0000000"
    For Each fl As String In dlg.FileNames
        If ftp1.Upload(fl,"\\localuser\\photo\\test\\" & e.DataRow("权利人") & ".jpg",True) = True Then
            Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        Else
            Messagebox.show("上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        End If
    Next
End If

 

 

以上代码放在 表事件(BeforeAddFile)中,点击 图片列窗口“增加“ 时执行,

1、消息窗口提示上传完成!!!, 而且能显示上传进度(进度条),但在ftp上找不到上传的文件????

2、在图片列没有填写进相应的图片地址数据,不是绑定的吗?要写代码填写吗???

 


--  作者:shenhq
--  发布时间:2014/6/2 22:56:00
--  

文件是上传了,是没刷新的原因。

 

写入图片列还是不行!

 

以下写的哪里不对?

 

If e.DataCol.name ="图片"
   
    Dim dlg As New OpenFileDialog
    dlg.MultiSelect = True
    dlg.Filter= "图片文件|*.jpg|图片文件|*.jpeg" \'设置筛选器
    If dlg.ShowDialog = DialogResult.OK Then
        Dim  ftp1 As  New  FtpClient
        ftp1.Host="220.211.220.211"
        ftp1.Account =  "ftpuser"
        ftp1.Password =  "000000"
        ftp1.RootDir = "/localuser/photo/" & e.DataRow("项目编号")
        For Each fl As String In dlg.FileNames
            Dim Randstr As String =Rand.NextString(6)
            If ftp1.Upload(fl, ftp1.RootDir & e.DataRow("档案编号")& e.DataRow("权利人") & Randstr & ".jpg",True) = True Then

                Dim lst As New List(of String)                \'写入图片列
                lst = e.DataRow.Lines("图片")
                lst.Add(ftp1.RootDir & e.DataRow("档案编号")& e.DataRow("权利人") & Randstr & ".jpg")
                Messagebox.show(fl & "-上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
            Else
                Messagebox.show( fl & "-上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
            End If
        Next
    End If
End If


--  作者:狐狸爸爸
--  发布时间:2014/6/3 11:42:00
--  
If e.DataCol.name ="图片"
    Dim dlg As New OpenFileDialog
    dlg.MultiSelect = True
    dlg.Filter= "图片文件|*.jpg|图片文件|*.jpeg" \'设置筛选器
    If dlg.ShowDialog = DialogResult.OK Then
        Dim  ftp1 As  New  FtpClient
        ftp1.Host="220.211.220.211"
        ftp1.Account =  "ftpuser"
        ftp1.Password =  "000000"
        ftp1.RootDir = "/localuser/photo/" & e.DataRow("项目编号")
        For Each fl As String In dlg.FileNames
            Dim Randstr As String =Rand.NextString(6)
            If ftp1.Upload(fl, ftp1.RootDir & e.DataRow("档案编号")& e.DataRow("权利人") & Randstr & ".jpg",True) = True Then
                If e.DataRow.Isnull("图片") Then
                    e.DataRow("图片") = e.DataRow("档案编号")& e.DataRow("权利人") & Randstr & ".jpg"
                Else
                    e.DataRow("图片")  = e.DataRow("图片") & vbcrlf & e.DataRow("档案编号")& e.DataRow("权利人") & Randstr & ".jpg"
                End If
                Messagebox.show(fl & "-上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
            Else
                Messagebox.show( fl & "-上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
            End If
        Next
    End If
End If

--  作者:shenhq
--  发布时间:2014/6/3 22:56:00
--  

        If ftp1.Upload(fl, ftp1.RootDir & e.DataRow("档案编号")& e.DataRow("权利人") & Randstr & ".jpg",True) = True Then
                If e.DataRow.Isnull("图片") Then
                    e.DataRow("图片") = e.DataRow("档案编号")& e.DataRow("权利人") & Randstr & ".jpg"
                Else
                    e.DataRow("图片")  = e.DataRow("图片") & vbcrlf & e.DataRow("档案编号")& e.DataRow("权利人") & Randstr & ".jpg"
                End If
                Messagebox.show(fl & "-上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
            Else
                Messagebox.show( fl & "-上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
            End If

请教:黄色的和红色的分别是什么意思??


--  作者:菲舍尔
--  发布时间:2014/6/4 2:31:00
--  

黄色是回车的意思

 

红色是原来的字段值

 

这句就是在原字段值的基础上加个回车再加你新的文件名

 


--  作者:shenhq
--  发布时间:2014/6/6 20:55:00
--  

谢谢。


--  作者:shenhq
--  发布时间:2014/6/6 21:04:00
--  
继续提问:同步删除FTP上的文件怎么处理呢?