2013-08-30 2 views
0

내 양식에서 일부 PDF 보고서를 열어야하는 프로젝트가 있습니다. 프로그램은 어떤 드라이브 에나 설치할 수 있기 때문에 winform 위치 디렉토리를 경로로 사용했습니다. 보고서는 Reports라는 디렉토리에 있습니다. Winform은 bin \ debug 아래에 있기 때문에 잘 작동하지만 솔루션을 배포하고 절차를 시도해도 작동하지 않습니다. 파일을 찾을 수 없습니다. 배포 후 Reports 디렉토리를 만들었지 만 여전히 내 pdf를 찾지 못했습니다.winform 프로젝트 내에있는 파일을 여는 방법

 '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 
+1

실행중인 OS가 UAC 문제 일 수 있습니다. 보통 Application Directory 대신 ProgramData Directory에 정보를 입력합니다. –

+0

@MarkHall Windows 8을 사용 중입니다. –

+0

* 파일을 찾을 수 없습니다. ** 배포 후 Reports 디렉토리 **를 만들었지 만 여전히 내 pdf를 찾지 못했습니다. * (어떻게) 파일을 배포합니까 ?? – Chris

답변

2

Application.StartupPath 대신 Directory.GetCurrentDirectory() 시도 : 여기

는 코드입니다. 나는 항상 그 물건으로 좋은 결과를 얻는다.

은 MSDN에서입니다 :

현재 디렉토리는 프로세스가 시작된 하나입니다 원래 디렉토리로 구별된다.