1

我有一个 DataGrid,它从数据库中的表中读取某些文件的名称和文件名(完整地址)。我想要的是当用户双击文件时,它会打开 PDF 阅读器并加载文件。我该怎么做呢?

编辑:这是我当前的代码:

        Dim row2 As String = DataGridView1.Rows(e.RowIndex).Cells(3).Value
    Process.Start("Acrobat.exe", row2)

VS 抛出找不到文件的异常。我检查了变量,它给了我正确的数据。我还尝试将 row2 放在引号之间,但也不行。它只是找不到文件。

工作更新:好吧,这是一个非常简单的错误

Process.Start("AcroRd32.exe", row2)

Row2 从数据网格中具有文件位置的单元格中获取数据。

4

1 回答 1

1

Process.Start("filename") will open a file using the default application on that machine.

In most cases, the above approach is correct. It is not dependent on a particular application or particular version of the application being pre-installed on the target machine. The advantage is loose coupling between your application and the PDF viewer.

If you really need to, you can use Process.Start() to launch a particular program, many of which will accept a filename as a command line parameter, like so:

Process.Start("IExplore.exe", "C:\myPath\myFile.htm")

(This example taken from the linked MSDN documentation)

You can find a list of Adobe Reader's command line arguments here:

Adobe Reader Command Line Reference

Update: The above link is old (focuses on version 7). You can find version 8 documentation here:

http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf

I cannot find a reference for version 9.

于 2013-06-10T18:29:22.420 回答