我有一個windows .net程序(除其他外)將顯示圖像文件。這些文件可以是TIFF或PDF格式,目前顯示的方式是查看文件擴展名,然後調用相應的程序來顯示該文件。.net Windows應用程序 - 如何通過文件關聯自動調用程序
下面的代碼片段:
imagepath = imagedataset.Tables("Table").Rows(imagecal).Item(2)
imagepath = "\\tylerimaging\DocumentUpload\" & imagedataset.Tables("Table").Rows(imagecal).Item(3) & "\" & imagedataset.Tables("table").Rows(imagecal).Item(4)
Dim PDFImage As String = imagepath.Substring(imagepath.Length - 3)
If UCase(PDFImage) = "PDF" Then
System.Diagnostics.Process.Start("AcroRd32.exe", imagepath)
Else
Try
System.Diagnostics.Process.Start("MSPVIEW.EXE", imagepath)
Catch ex As Exception
If ex.Message = "The system cannot find the file specified" Then
System.Diagnostics.Process.Start("ois.exe", imagepath)
End If
End Try
End If
End If
現在的問題是,如果有人沒有安裝Acrobat Reader,例如,而是使用Adobe Acrobat的完整版,爲的Process.Start AcroRd32 .exe將失敗。但是,Windows顯然具有PDF和Acrobat文件類型之間的關聯 - 所以,這裏是我的問題 - 如何通過與Windows中的該文件類型關聯的任何程序顯示文件?
在此先感謝....
是相關http://stackoverflow.com/questions/258416/shellexecute-equivalent-in-net – Jeremy