全部;
我有一些我写的代码,当我扫描条形码时,它会打开设计蓝图。它工作得很好,但我想打开设计软件(Solidworks)的一个新实例,并在新实例中显示打印内容。现在,无论我打开了多少个Solidworks实例,打印都只会在第一个实例启动时打开。
下面注释掉的行是可以工作的行,只是不在正确的实例中。下面的代码行是我所期望的,但是它返回了一个'file not found‘,即使solidworks的路径和打印路径都是正确的。
任何关于为什么这个方法不起作用的解释都将不胜感激,因为我显然是this...and的新手,不知道我在做什么。
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim barcode As String = tb_barcode.Text
Dim filename As String = tb_barcode.Text
'Add File Extension to end of path
Dim ext As String = ".SLDDRW"
'Split job number from detail number in barcode textbox
barcode = Split(tb_barcode.Text, ".")(0)
filename = Split(tb_barcode.Text, ".")(1)
'- This works, just in primary instance
'System.Diagnostics.Process.Start("G:\Fixtures\" & barcode & "\Details\" & barcode & " DET " & filename & ext)
'- This does not work
System.Diagnostics.Process.Start("'C:\Program files\Solidworks Corp\Solidwork\SLDWORKS.exe' 'G:\Fixtures\" & barcode & "\Details\" & barcode & " DET " & filename & ext + "'")
Catch
MessageBox.Show("File Not Found")
End Try
End Sub发布于 2018-11-27 03:16:01
抱歉,我的方法很幼稚,但是Process.Start中的两个参数之间不应该有一个逗号吗?
Start(String, String) 通过指定应用程序的名称和一组命令行参数来启动进程资源,并将该资源与新的进程组件相关联。docs
发布于 2018-11-27 08:55:05
为什么不使用Application.ExecutablePath.That返回应用程序的路径及其全名。那么你的代码应该是
System.Diagnostics.Process.Start(Application.Executablepath, "G:\Fixtures\" & barcode & "\Details\" & barcode & " DET " & filename & ext + "'")还要确保第二个字符串参数是有效路径。
https://stackoverflow.com/questions/53487270
复制相似问题