我有一个项目需要从我的表单中打开一些 pdf 报告。由于该程序可以安装在任何驱动器中,因此我使用 winform 位置目录作为我的路径。我的报告位于名为 Reports 的目录中。它在开发中运行良好,因为我的 winform 在 bin\debug 下,但是当我部署我的解决方案并尝试该过程时,它不起作用,找不到文件。我在部署后创建了一个 Reports 目录,但仍然没有找到我的 pdf。
这是代码:
'Open the requested file name. The files are stored in the
'same path as the main workbook.
'@param filename file to be opened
Function OpenReports(strFileName As String) As String
Dim reportFolder As String
Try
reportFolder = Path.Combine(Directory.GetCurrentDirectory(), "Reports")
System.Diagnostics.Process.Start(reportFolder & "\" & strFileName)
Catch ex As Exception
MsgBox("The " & strFileName & " is not found on directory")
End Try
Return strFileName
End Function
Private Sub btnRptRangesToMarket_Click(sender As Object, e As EventArgs) Handles btnRptRangesToMarket.Click
'This procedure runs when the btnRptRangesToMarket is clicked
'the procedure opens the pdf below by running the OpenReports Function
OpenReports("Ranges to Market.pdf")
End Sub