【问题标题】:OpenFileDialog under the hood引擎盖下的 OpenFileDialog
【发布时间】:2012-05-30 12:13:12
【问题描述】:

这是我在这里的第一个问题,因为我最终陷入了死胡同。 我正在使用 ZIP 2 Secure EXE(来自 Chilkat 的非常好的软件)为应用程序创建 setup.exe。 ZIP 2 Secure EXE 可以在没有 GUI 的情况下使用一个或多个参数运行。
问题是,当我调用 ZIP 2 Secure EXE (ChilkatZipSE.exe) 而不使用 OpenFileDialog 表单来确定 ChilkatZipSE.exe 的位置时,它不会使用 System.Diagnostics.Process 类运行进程。我调用 ChilkatZipSE.exe 的方式是“..\ChilkatZipSE.exe -cfg settings.xml”。 settings.xml 一切正常,并且有创建 setup.exe 文件所需的 UnlockCode 节点。当我使用 OpenFileDialog ChilkatZipSE.exe 创建所需的 setup.exe 并且它工作正常。
下面是我使用的代码:

Private Sub btnStartApp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStartApp.Click

    If txtExtAppPath.Text.Length > 0 AndAlso System.IO.File.Exists(txtExtAppPath.Text) Then

        Dim myFile As New FileInfo(txtExtAppPath.Text)
        txtExtAppLog.Text = StartApplication(myFile.FullName, txtExtParams.Text, chkIsHidden.Checked)
        'txtExtAppLog.Text = StartApplication(txtExtAppPath.Text, txtExtParams.Text, chkIsHidden.Checked)

    End If

End Sub

Public Function StartApplication(ByVal fileFullPath_ As String, ByVal fileParameter_ As String, ByVal isHidden_ As Boolean) As String

    Dim lassie As String = String.Empty

    Try

        Dim newProcess As New ProcessStartInfo()
        newProcess.FileName = fileFullPath_
        newProcess.Arguments = fileParameter_
        If isHidden_ Then newProcess.WindowStyle = ProcessWindowStyle.Hidden

        If System.IO.File.Exists(fileFullPath_) Then

            Using startedNewProcess As Process = Process.Start(newProcess)
                'startedNewProcess.EnableRaisingEvents = True
                startedNewProcess.WaitForExit()
            End Using

        Else

            lassie = "File " + fileFullPath_ + " doesn't exist."

        End If

    Catch ex As Exception

        lassie = ex.Message

    End Try

    Return lassie

End Function

谢谢,万能。

【问题讨论】:

  • 问题出在给定的参数上。使用 OpenFileDialog 时,它知道 settings.xml 的位置。但是,在没有 OpenFileDialog 的情况下调用“..\ChilkatZipSE.exe -cfg settings.xml”时,它必须用作“..\ChilkatZipSE.exe -cfg ..\settings.xml”。无论如何,谢谢大家,再见。
  • 所以回答您的问题,并标记为已接受,或者删除问题。

标签: vb.net openfiledialog


【解决方案1】:

问题出在给定的参数上。使用 OpenFileDialog 时,它知道 settings.xml 的位置。但是在没有 OpenFileDialog 的情况下调用“..\ChilkatZipSE.exe -cfg settings.xml”时,它必须用作“..\ChilkatZipSE.exe -cfg ..\settings.xml”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-01
    • 1970-01-01
    • 2018-03-03
    • 1970-01-01
    • 1970-01-01
    • 2017-06-02
    相关资源
    最近更新 更多