以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  WebBrowser远程打开ftp文件  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=160891)

--  作者:lisangyu
--  发布时间:2021/2/25 11:37:00
--  WebBrowser远程打开ftp文件
蓝总: 利用WebBrowser远程下载ftp文件,对下载的文件doc docx xls xlsx强制转换为mht格式 后再在WebBrowser中打开,对于pdf或照片在WebBrowser中自动打开。请问有实例吗
Dim ftp1 As new ftpclient
ftp1.host="10.60.128.146"
ftp1.Account = "ftpuser"
ftp1.password = "bnm,./123"
If ftp1.Download("\\ & Tables("知识文档").Current("路径")","\\RemoteFiles\\ & Tables("知识文档").Current("文件名")" = True Then 
[此贴子已经被作者于2021/2/25 11:37:11编辑过]

--  作者:有点蓝
--  发布时间:2021/2/25 11:48:00
--  
保存到本机,直接设置即可

Dim web As WinForm.WebBrowser = e.Form.Controls("WebBrowser1")
web
.Address = 上面保存的文件的路径

--  作者:lisangyu
--  发布时间:2021/2/25 15:21:00
--  
Dim ftp1 As new ftpclient
ftp1.host="10.60.128.146"
ftp1.Account = "ftpuser"
ftp1.password = "bnm,./123"
Dim lj As String = Tables("知识文档").Current("路径")
Dim fp As String = "\\myftp\\管理规定" & lj
Dim wjm As String = Tables("知识文档").Current("文件名")
If wjm IsNot Nothing Then
    If ftp1.Download(fp,"\\RemoteFiles\\" & wjm) = True Then
        Messagebox.show("下载完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Else
        Messagebox.show("下载失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    End If
End If

上面代码哪里出错了?下载失败

--  作者:有点蓝
--  发布时间:2021/2/25 15:25:00
--  
If Tables("知识文档").Current IsNot Nothing Then
Dim ftp1 As new ftpclient
ftp1.host="10.60.128.146"
ftp1.Account = "ftpuser"
ftp1.password = "bnm,./123"
Dim lj As String = Tables("知识文档").Current("路径")
Dim fp As String = "\\myftp\\管理规定" & lj
Dim wjm As String = Tables("知识文档").Current("文件名")
msgbox(projectpath & "RemoteFiles\\" & wjm)
    If ftp1.Download(fp,projectpath & "RemoteFiles\\" & wjm) = True Then
        Messagebox.show("下载完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Else
        Messagebox.show("下载失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    End If
End If

--  作者:lisangyu
--  发布时间:2021/2/25 15:54:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:1.jpg
图片点击可在新窗口打开查看

If Tables("主窗口_table1").Current IsNot Nothing Then
    Dim ftp1 As new ftpclient
    ftp1.host="10.60.128.146"
    ftp1.Account = "ftpuser"
    ftp1.password = "bnm,./123"
    Dim lj As String = Tables("主窗口_table1").Current("路径")
    Dim fp As String = "\\myftp\\管理规定" & lj
    Dim wjm As String = Tables("主窗口_table1").Current("文件名")
    msgbox(projectpath & "RemoteFiles\\" & wjm)
    If ftp1.Download(fp,projectpath & "RemoteFiles\\" & wjm) = True Then
        Messagebox.show("下载完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Else
        Messagebox.show("下载失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    End If
End If

还是提示下载失败了

--  作者:有点蓝
--  发布时间:2021/2/25 15:58:00
--  
确定RemoteFiles这个目录是否存在?

确定ftp这个路径的文件存在?"\\myftp\\管理规定" & lj

[此贴子已经被作者于2021/2/25 15:57:43编辑过]

--  作者:lisangyu
--  发布时间:2021/2/25 16:03:00
--  
对的,lj错了,我已经改了。辛苦了,蓝总
--  作者:lisangyu
--  发布时间:2021/2/25 16:51:00
--  
If Tables("主窗口_table1").Current IsNot Nothing Then
    Dim ftp1 As new ftpclient
    ftp1.host="10.60.128.146"
    ftp1.Account = "ftpuser"
    ftp1.password = "bnm,./123"
    Dim lj As String = Tables("主窗口_table1").Current("路径")
    Dim fp As String = lj
    Dim wjm As String = Tables("主窗口_table1").Current("文件名")
    Dim hz As String = Tables("主窗口_table1").current("后缀")
    msgbox(projectpath & "RemoteFiles\\" & wjm)
    If ftp1.Download(fp,projectpath & "RemoteFiles\\" & wjm) = True Then
        e.Form.text = "浏览器   正在打开中...."
        If hz = "doc" Or "docx" Or "xls" Or "xlsx" Then

        End If
        
        
    Else
        e.Form.text = "浏览器   打开失败...."
    End If
End If

蓝总:  能不能利用SaveToMHT  对下载的office文件直接转为MHT,在webbrrowser 显示呢

--  作者:有点蓝
--  发布时间:2021/2/25 17:24:00
--  
下载后,转换,然后把转换后的文件路径设置到webbrrowser即可
--  作者:lisangyu
--  发布时间:2021/2/26 8:39:00
--  
 Dim ftp1 As new ftpclient
    ftp1.host="10.60.128.146"
    ftp1.Account = "ftpuser"
    ftp1.password = "bnm,./123"
    Dim lj As String = Tables("主窗口_table1").Current("路径")
    Dim fp As String = lj
    Dim wjm As String = Tables("主窗口_table1").Current("文件名")
    Dim hz As String = Tables("主窗口_table1").current("后缀")
    msgbox(projectpath & "RemoteFiles\\" & wjm)
    If ftp1.Download(fp,projectpath & "RemoteFiles\\" & wjm) = True Then
        e.Form.text = "浏览器   正在打开中...."
        If hz = "doc" Or hz =  "docx" Then
            Dim tmp As String  =  projectpath & "RemoteFiles\\" & wjm
            Dim mht As String =  projectpath & "RemoteFiles\\ & wjm & .mhtml"
            Dim app As New MSWord.Application
            Dim doc = app.Documents.Open(tmp)
            doc.SaveAs(Filename:=mht , FileFormat:=MSWord.WdSaveFormat.wdFormatWebArchive)
            app.quit
            e.Form.text = "浏览器"
            e.Form.Controls("WebBrowser1").Address = mht
蓝总:早上好!现在能将WORD转为MHTML格式并在窗口打开,但是mht的定义路径 写的有问题,转换的文件名变成“& wjm & .mhtml”,不能正常显示文件名,每次文件名都一样,导致转换卡顿。