以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  求助FTP 重命名  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=70906)

--  作者:lingyun00800
--  发布时间:2015/7/1 10:32:00
--  求助FTP 重命名
做了个上传按钮
Dim dlg As new  OpenFileDialog
If dlg.ShowDialog = DialogResult.OK Then
    Dim xg As Integer = dlg.FileName.LastIndexOf("\\")
    Dim fname As String = dlg.FileName.SubString(xg + 1) 
   
    Dim ftp As new FTPClient
    ftp.Host = "222.172.***.***"
    ftp.Account = "*****"
    ftp.Password = "****"
   
    ftp.ChangeDir("\\UpLoadFile")    \'进入UpLoadFile
    Dim fp As String = "\\UpLoadFile"
    If ftp.Upload(dlg.FileName,fp & "\\" & fname) = True Then
        Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Else
        Messagebox.show("上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    End If
End If

我想实现 上传文件名称改为 服务器系统时间+UserName
然后把 网页下载路径写入 “表A”的“第一列”

就是用窗口的按钮上传文件,在表中的单元格中,点击下载。

--  作者:大红袍
--  发布时间:2015/7/1 10:34:00
--  

这个意思?

 

If ftp.Upload(dlg.FileName,fp & "\\" & Format(date.Now, "yyyyMMddHHmmss") & user.Name & fname) = True Then


--  作者:lingyun00800
--  发布时间:2015/7/1 10:39:00
--  
 是重命名为 服务器系统时间+user.name
--  作者:lingyun00800
--  发布时间:2015/7/1 10:45:00
--  
 是重命名为 服务器系统时间+user.name 

--  作者:大红袍
--  发布时间:2015/7/1 10:47:00
--  

 无法获取ftp系统时间,只能这样做

 

Dim ftpName As String = fp & "\\" & Format(Date.Now, "yyyyMMddHHmmss") & user.Name & fname
If ftp.Upload(dlg.FileName,ftpname) = True Then
    Dim sz As Date = ftp.GetFileTime(ftpName)
    ftp.Rename(ftpName, fp & "\\" & Format(sj, "yyyyMMddHHmmss") & user.Name)
    Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
    Messagebox.show("上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If

[此贴子已经被作者于2015/7/1 10:47:20编辑过]

--  作者:lingyun00800
--  发布时间:2015/7/1 11:33:00
--  
 改完的文件。没有尾缀。。怎么弄??

--  作者:大红袍
--  发布时间:2015/7/1 11:36:00
--  
 Dim dlg As new  OpenFileDialog
If dlg.ShowDialog = DialogResult.OK Then
    Dim xg As Integer = dlg.FileName.LastIndexOf(".")
    Dim hz As String = dlg.FileName.SubString(xg)
   
    Dim ftp As new FTPClient
    ftp.Host = "222.172.***.***"
    ftp.Account = "*****"
    ftp.Password = "****"
   
    ftp.ChangeDir("\\UpLoadFile")    \'进入UpLoadFile
    Dim fp As String = "\\UpLoadFile"
    Dim ftpName As String = fp & "\\" & Format(Date.Now, "yyyyMMddHHmmss") & user.Name & hz
    If ftp.Upload(dlg.FileName,ftpname) = True Then
        Dim sz As Date = ftp.GetFileTime(ftpName)
        ftp.Rename(ftpName, fp & "\\" & Format(sz, "yyyyMMddHHmmss") & user.Name & hz)
        Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Else
        Messagebox.show("上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    End If   
End If