加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

没有应用程序与此操作的指定文件关联(VB.NET)

发布时间:2020-12-17 00:21:52 所属栏目:大数据 来源:网络整理
导读:我们有一个Win Forms应用程序,它生成带有iTextSharp的pdf,将其保存到本地目录,然后应用程序打开该文件.有一个客户(所有XP盒和Adobe Reader 11),它会抛出以下错误 No application is associated with the specified file for this operationat System.Diagnos
我们有一个Win Forms应用程序,它生成带有iTextSharp的pdf,将其保存到本地目录,然后应用程序打开该文件.有一个客户(所有XP盒和Adobe Reader 11),它会抛出以下错误
No application is associated with the specified file for this operation
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()

这表明Adobe Reader与pdf扩展名没有正确关联,除了他们可以导航到本地目录并打开文件而没有任何问题.

以前有人遇到过这种奇怪的事吗?

编辑重新ZippyV – 典型子的示例

Public Sub PDF_Functions_LogCalls_RunReport(ByVal Customer As Boolean)
    Try
        Dim vOutput As String = LogCalls_Run(Customer)
        If Left(vOutput,5) = "Error" Then
            TaskDialog.Show(MainForm,AppBoxError("File Error",vOutput,"Error"))
            Exit Sub
        End If
        If System.IO.File.Exists(vOutput) Then
            Dim P As New Process
            P.StartInfo.FileName = vOutput
            P.StartInfo.Verb = "Open"
            P.Start()
        End If
    Catch ex As Exception
        EmailError(ex)
        Exit Sub
    End Try
End Sub
您正在阅读错误消息错误.我更加强调相关部分:

No application is associated with the specified file for this operation

这意味着没有与动词“打开”相关联的应用程序.更改您的代码只需使用空字符串(或只是不设置)动词:

P.StartInfo.FileName = vOutput
P.StartInfo.Verb = ""
P.Start()

这使用.pdf格式的默认操作,它将匹配用户在Windows资源管理器中双击文件时将获得的操作.

最新版本的Acrobat将默认操作设置为“使用Adobe Reader XI打开”而不仅仅是“打开”,因为您可以看到右键单击.pdf文件.

这似乎是导致“与此操作无关”错误的原因.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读