如何在Visual Basic 2010中打开程序?

时间:2010-08-06 16:54:52

标签: vb.net process

如何在Visual Basic 2010中打开程序? (例如在Visual Basic项目中运行“C:\”中的“Application.txt”。

    Public Class getfrom

        Dim getfrom As String
        Dim saveto As String
        Dim download As Boolean

        Function openRunt()
            Dim myProcess As New Process()
            Try

                myProcess.StartInfo.UseShellExecute = False
                myProcess.StartInfo.FileName = "C:\\Runt.exe"
                myProcess.StartInfo.CreateNoWindow = True
                myProcess.Start()
            Catch e As Exception
                ' do nothing.
            End Try
            Return False
        End Function

        Function setVariables()
            ' Download the file from..
            getfrom = "http://sourceforge.net/projects/iforsm/files/iForsm.exe"
            ' Download the file to..
            saveto = "C:\Runt.exe"
            ' Allow download..
            download = True

            Return False
        End Function

        Private Sub getfrom_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            setVariables()
            If download = True Then
                My.Computer.Network.DownloadFile(getfrom, saveto)
                Dim fileExists As Boolean
                fileExists = My.Computer.FileSystem.FileExists("C:\Runt.exe")
                If fileExists = True Then
                    'System.Diagnostics.Process.Start("notepad.exe", "c:\Application.txt")
                    openRunt()
                End If
            Else
                End
            End If
            'End
        End Sub
End Class

2 个答案:

答案 0 :(得分:4)

如果您的意思是通过应用程序使用记事本程序打开文本文件,那么类似下面的内容应该可以解决问题。

System.Diagnostics.Process.Start("notepad.exe", "c:\Application.txt")

请参阅:http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx

答案 1 :(得分:0)

您将使用ProcessStart机制,请参阅下面的链接以获取教程。

它位于System.Diagnostics名称空间内。

由于 皮特

Process Start Tutorial