Foxtable(狐表)用户栏目专家坐堂 → [求助]ftp如何直接连接到已有的绝对路径?


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

主题:[求助]ftp如何直接连接到已有的绝对路径?

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


加好友 发短信
等级:三尾狐 帖子:633 积分:4034 威望:0 精华:0 注册:2014/6/23 10:27:00
[求助]ftp如何直接连接到已有的绝对路径?  发帖心情 Post By:2015/3/18 16:27:00 [显示全部帖子]

当“发布目录”没有内容,是直接打开FTP管理器,然后创建目录,上传文件等等。
但是呢当发布目录有内容,内容就是一个绝对路径,希望直接ftp到这个绝对路径。如何else呢?
If e.Col.Name = "发布目录" Then
    e.Cancel= True
    If e.Row.IsNull("发布目录")= True Then 
    Forms("FTP管理器").open
Else
***********
End If

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


加好友 发短信
等级:三尾狐 帖子:633 积分:4034 威望:0 精华:0 注册:2014/6/23 10:27:00
  发帖心情 Post By:2015/3/18 16:53:00 [显示全部帖子]

CellButtonClick:
If e.Col.Name = "发布目录" Then
    e.Cancel= True
    If e.Row.IsNull("发布目录")= True Then
        Forms("FTP管理器").open
    Else
        vars("路径") = e.Row("发布目录")
        Dim ftp As New FtpClient
        ftp.Host="192.168.1.35"
        ftp.Account = "tester"
        ftp.Password = "tester"
        ftp.RootDir = vars("路径")
        msgbox(vars("路径"))--------弹出的路径倒是对的,就是ftp没有连接。
    End If
End If
afterload:并没有改,因为afterload创建是ml目录,不知道再怎么让ftp按照vars(“路径”)来打开。
Dim ftp As New FtpClient
ftp.Host="192.168.1.35"
ftp.Account = "tester"
ftp.Password = "tester"

ftp.ChangeDir("/待用户现场确认版本_产线禁止使用/2015")   '进入到待用户现场确认版本_产线禁止使用\2015目录
Dim lj As String = "/待用户现场确认版本_产线禁止使用/2015/" & Tables("临时版本跟踪表").current("临时版本编号") & "(" & Tables("临时版本跟踪表").current("客户") & "_" & Tables("临时版本跟踪表").current("博达机型") & ")"

If ftp.DirExists(lj) = False Then   '不存在临时版本编号目录时先创建临时版本编号目录
    ftp.MakeDir(lj)
End If
Dim ml As String = lj  & "/" & Format(Date.now, "yyyy-MM-dd HH-mm-ss")
If ftp.DirExists(ml) = False Then  '按照系统时间来创建时间目录
    ftp.MakeDir(ml)
End If
Tables("临时版本跟踪表").Current("发布目录") = ml
vars("zhygwjj") = ml

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


加好友 发短信
等级:三尾狐 帖子:633 积分:4034 威望:0 精华:0 注册:2014/6/23 10:27:00
  发帖心情 Post By:2015/3/18 17:16:00 [显示全部帖子]

这样不行吧,不打开ftp了?

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


加好友 发短信
等级:三尾狐 帖子:633 积分:4034 威望:0 精华:0 注册:2014/6/23 10:27:00
  发帖心情 Post By:2015/3/18 17:49:00 [显示全部帖子]

我没说清楚。
不是打开默认的ftp。仍然是打开FTP管理器窗口。只不过FTP管理器的afterload不是每次都自动创建子目录ml么。
只有当发表目录为空,那么打开FTP管理器那是对的,会自动按照时间创建目录。
但是呢,当发布目录已经有了路径,那么打开的应该是这个路径的FTP,仍然是FTP管理器窗口,只不过这样又执行了一次afterload,又创建了一个新的时间目录。而不是打开已有的ftp路径。
就是有这个矛盾,不知道该怎么弄。

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


加好友 发短信
等级:三尾狐 帖子:633 积分:4034 威望:0 精华:0 注册:2014/6/23 10:27:00
  发帖心情 Post By:2015/3/19 10:15:00 [显示全部帖子]

afterload如下:
但是呢Tables("临时版本跟踪表").current("发布目录") = lj却没执行。导致发布目录的值仍然为空,正常情况应是当发布目录为空,执行下面的代码后发布目录应该是一个路径才对。
If vars("路径") = "" Then
Dim ftp As New FtpClient
ftp.Host="192.168.1.35"
ftp.Account = "tester"
ftp.Password = "tester"

ftp.ChangeDir("/待用户现场确认版本_产线禁止使用/2015")   '进入到待用户现场确认版本_产线禁止使用\2015目录
Dim lj As String = "/待用户现场确认版本_产线禁止使用/2015/" & Tables("临时版本跟踪表").current("临时版本编号") & "(" & Tables("临时版本跟踪表").current("客户") & "_" & Tables("临时版本跟踪表").current("博达机型") & ")"

If ftp.DirExists(lj) = False Then   '不存在临时版本编号目录时先创建临时版本编号目录
    ftp.MakeDir(lj)
End If
Dim ml As String = lj  & "/" & Format(Date.now, "yyyy-MM-dd HH-mm-ss")
If ftp.DirExists(ml) = False Then  '按照系统时间来创建时间目录
    ftp.MakeDir(ml)
End If
Tables("临时版本跟踪表").current("发布目录") = lj
vars("zhygwjj") = ml

msgbox(vars("路径"))
ftp.Close
Else
Functions.Execute("listview")
End If


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


加好友 发短信
等级:三尾狐 帖子:633 积分:4034 威望:0 精华:0 注册:2014/6/23 10:27:00
  发帖心情 Post By:2015/3/19 10:26:00 [显示全部帖子]

是这一块我弄错了。
应该为下面的才对。我之前在这就开始判断发布目录是否为空,实际上没必要,在这直接打开FTP管理器窗口就行,然后在afterload在判断发布目录是否为空就成,对吧。
If e.Col.Name = "发布目录" Then
    e.Cancel= True
    vars("路径") = e.Row("发布目录")
    Forms("FTP管理器").open
End If

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


加好友 发短信
等级:三尾狐 帖子:633 积分:4034 威望:0 精华:0 注册:2014/6/23 10:27:00
  发帖心情 Post By:2015/3/19 10:36:00 [显示全部帖子]

afterload代码如下:
If vars("路径") = "" Then
Dim ftp As New FtpClient
ftp.Host="192.168.1.35"
ftp.Account = "tester"
ftp.Password = "tester"



ftp.ChangeDir("/待用户现场确认版本_产线禁止使用/2015")   '进入到待用户现场确认版本_产线禁止使用\2015目录
Dim lj As String = "/待用户现场确认版本_产线禁止使用/2015/" & Tables("临时版本跟踪表").current("临时版本编号") & "(" & Tables("临时版本跟踪表").current("客户") & "_" & Tables("临时版本跟踪表").current("博达机型") & ")"

If ftp.DirExists(lj) = False Then   '不存在临时版本编号目录时先创建临时版本编号目录
    ftp.MakeDir(lj)
End If
Dim ml As String = lj  & "/" & Format(Date.now, "yyyy-MM-dd HH-mm-ss")
If ftp.DirExists(ml) = False Then  '按照系统时间来创建时间目录
    ftp.MakeDir(ml)
End If
Tables("临时版本跟踪表").current("发布目录") = lj
vars("zhygwjj") = ml

msgbox(lj)
ftp.Close
Else
Functions.Execute("listview")----执行listview
End If

listview代码如下:
Dim ftp As New FtpClient
ftp.Host="192.168.1.35"
ftp.Account = "tester"
ftp.Password = "tester"

Dim lvw As WinForm.ListView = Forms("FTP管理器").Controls("ListView1")
lvw.Rows.Clear
lvw.Images.Clear
lvw.Images.LargeSize = new size(32,32)

Dim  ics As String() = {"swf","accdb","mdb","psd","png","xls","xlsx","bmp","rar","jpg","doc","docx","zip","pdf","txt","ppt","exe","bin","map","other"}  '定义扩展名数组
Dim kzms As String ="swf accdb mdb psd png xls xlsx bmp rar jpg doc docx zip pdf txt ppt exe bin map"  '定义已知扩展名的文本串
For Each ic As String In ics
    lvw.Images.AddImage(ic,ic & ".png",ic & ".png") 
Next

Dim sts As List(of String) = ftp.GetFileList(vars("zhygwjj"))
If sts.Count > 0 Then  '若有文件
    For Each st As String In sts
        Dim r As WinForm.ListViewRow = lvw.Rows.Add   
        Dim Dot As Integer = st.LastIndexOf(".")  
        Dim kzm As String = st.SubString(Dot + 1)  
        r.text = st
        If kzms.Contains(kzm) = True Then   
            r.ImageKey = kzm  
        Else
            r.ImageKey = "other"
        End If
    Next
End If
ftp.Close

发现这样做发布目录是正确的,可是呢。当发布路径有值了,不论你FTP任何一个发布目录,都listview都是一样的文件,而且是最后一次上传的文件。
正常情况2个不同的FTP路径,链接后文件是不一样的。

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


加好友 发短信
等级:三尾狐 帖子:633 积分:4034 威望:0 精华:0 注册:2014/6/23 10:27:00
  发帖心情 Post By:2015/3/19 10:52:00 [显示全部帖子]

但是vars("zhygwjj")不应该只是当前发布目录的最后一个文件夹吗?,不应该不同的发布目录显示出同一个文件夹文件。
Dim lj As String = "/待用户现场确认版本_产线禁止使用/2015/" & Tables("临时版本跟踪表").current("临时版本编号") & "(" & Tables("临时版本跟踪表").current("客户") & "_" & Tables("临时版本跟踪表").current("博达机型") & ")"

If ftp.DirExists(lj) = False Then   '不存在临时版本编号目录时先创建临时版本编号目录
    ftp.MakeDir(lj)
End If
Dim ml As String = lj  & "/" & Format(Date.now, "yyyy-MM-dd HH-mm-ss")
If ftp.DirExists(ml) = False Then  '按照系统时间来创建时间目录
    ftp.MakeDir(ml)
End If
Tables("临时版本跟踪表").current("发布目录") = lj
vars("zhygwjj") = ml

就是想当发布目录有值(路径)时,直接FTP这个路径到之前的创建的最后一个文件夹并显示之前上传的文件。

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


加好友 发短信
等级:三尾狐 帖子:633 积分:4034 威望:0 精华:0 注册:2014/6/23 10:27:00
  发帖心情 Post By:2015/3/19 11:21:00 [显示全部帖子]

If vars("路径") = "" Then
Dim ftp As New FtpClient
ftp.Host="192.168.1.35"
ftp.Account = "tester"
ftp.Password = "tester"

ftp.ChangeDir("/待用户现场确认版本_产线禁止使用/2015")   '进入到待用户现场确认版本_产线禁止使用\2015目录
Dim lj As String = "/待用户现场确认版本_产线禁止使用/2015/" & Tables("临时版本跟踪表").current("临时版本编号") & "(" & Tables("临时版本跟踪表").current("客户") & "_" & Tables("临时版本跟踪表").current("博达机型") & ")"

If ftp.DirExists(lj) = False Then   '不存在临时版本编号目录时先创建临时版本编号目录
    ftp.MakeDir(lj)
End If
Dim ml As String = lj  & "/" & Format(Date.now, "yyyy-MM-dd HH-mm-ss")
If ftp.DirExists(ml) = False Then  '按照系统时间来创建时间目录
    ftp.MakeDir(ml)
End If
Tables("临时版本跟踪表").current("发布目录") = ml
vars("zhygwjj") = ml

msgbox(lj)
ftp.Close
Else
vars("zhygwjj") = Tables("临时版本跟踪表").current("发布目录")----指定了vars(“zhygwjj”)的值
msgbox(vars("zhygwjj"))-------弹出框显示的也是最后一个文件夹的路径
Functions.Execute("listview")-----执行listview时,listview内容为空。不显示已经上传的文件,实际上是有文件的。
End If

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


加好友 发短信
等级:三尾狐 帖子:633 积分:4034 威望:0 精华:0 注册:2014/6/23 10:27:00
  发帖心情 Post By:2015/3/19 11:42:00 [显示全部帖子]

加了如下代码。但是连msgbox框都没弹出来。
Dim fls As List(of String)
fls = ftp.GetFileList(vars("zhygwjj"))
For Each fl As String In fls
    msgbox(fl)
Next

 回到顶部
总数 14 1 2 下一页