Foxtable(狐表)用户栏目专家坐堂 → [求助]这个ftp代码有问题!


  共有3409人关注过本帖树形打印复制链接

主题:[求助]这个ftp代码有问题!

帅哥哟,离线,有人找我吗?
shenhq
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:194 积分:1580 威望:0 精华:0 注册:2013/12/8 22:48:00
[求助]这个ftp代码有问题!  发帖心情 Post By:2014/6/2 21:46:00 [只看该作者]

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
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:194 积分:1580 威望:0 精华:0 注册:2013/12/8 22:48:00
  发帖心情 Post By: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


 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47448 积分:251060 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By: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
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:194 积分:1580 威望:0 精华:0 注册:2013/12/8 22:48:00
  发帖心情 Post By: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

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


 回到顶部
帅哥哟,离线,有人找我吗?
菲舍尔
  5楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:504 积分:3492 威望:0 精华:3 注册:2012/11/13 15:49:00
  发帖心情 Post By:2014/6/4 2:31:00 [只看该作者]

黄色是回车的意思

 

红色是原来的字段值

 

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

 


 回到顶部
帅哥哟,离线,有人找我吗?
shenhq
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:194 积分:1580 威望:0 精华:0 注册:2013/12/8 22:48:00
  发帖心情 Post By:2014/6/6 20:55:00 [只看该作者]

谢谢。


 回到顶部
帅哥哟,离线,有人找我吗?
shenhq
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:194 积分:1580 威望:0 精华:0 注册:2013/12/8 22:48:00
  发帖心情 Post By:2014/6/6 21:04:00 [只看该作者]

继续提问:同步删除FTP上的文件怎么处理呢?

 回到顶部