以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]打开文件能指定用什么软件吗?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=179087)

--  作者:2425004926
--  发布时间:2022/8/6 18:54:00
--  [求助]打开文件能指定用什么软件吗?
打开文件能指定用什么软件吗?
比如下面,有txt文件,htm文件,能指定都用记事本打开吗?

    Dim f As String = ProjectPath & "Attachments\\html\\" & dr("页面") & dr("扩展名")
    If FileSys.FileExists(f) Then
        Dim Proc As New Process \'定义一个新的Process
        Proc.File = f
        Proc.Start()
    End If

[此贴子已经被作者于2022/8/6 19:09:13编辑过]

--  作者:有点蓝
--  发布时间:2022/8/7 20:16:00
--  
这个要看指定的软件是否支持命令行参数打开文件。支持的就可以,比如记事本:

Dim Proc As New Process
Proc.File = "notepad"
Proc.Arguments = "D:\\web\\test.html"
Proc.Start

--  作者:2425004926
--  发布时间:2022/8/9 11:28:00
--  
    
感谢老师!这下如果发现错误更改太方便了!
    \'打开文件
    Dim f As String = ProjectPath & "Attachments\\html\\" & dr("页面") & dr("扩展名")
    If FileSys.FileExists(f) Then
        Select Case dr("扩展名")
            Case ".txt", ".htm", ".html"
                Dim Proc As New Process
                Proc.File = "notepad" \'用记事本打开
                Proc.Arguments = f
                Proc.Start
        End Select
    End If