我有一个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