2013-07-16 3 views
0

어떤 이유로 네트워크 이름을 찾을 수 없습니다. "myUniqueFileName"을 pdfwriter 행에 적용하려고하면 오류가 발생합니다. 그래서 그것은 아래 첫 번째 코드 줄을 사용하기 때문에 권한 문제가 아닙니다. 어떤 아이디어?네트워크 이름을 찾을 수 없습니다.

이 (경로가 발견)

PdfWriter.GetInstance(Doc1, New FileStream(path & "/Doc1.pdf", FileMode.Create)) 

이이 완료 코드

입니다

PdfWriter.GetInstance(Doc1, New FileStream(path & myUniqueFileName, FileMode.Create)) 

작동하지 않습니다 작동

Dim Doc1 As New Document 
    Dim path As String = "\\ServerAddress\PDFs" 
    Dim myUniqueFileName = String.Format("{0}.pdf", Guid.NewGuid()) 
    PdfWriter.GetInstance(Doc1, New FileStream(path & myUniqueFileName, FileMode.Create)) 
    Doc1.Open() 
    Dim test As String 
    test = Session("PDF") 
    Doc1.Add(New Paragraph(test)) 

    Doc1.Close() 
+1

다음을 실행합니다. 'Dim combinedData As String = path & myUniqueFileName'을 실행하고 디버깅하는 동안 문자열이 어떻게 보이는지 확인합니다. 이스케이프 처리 된 문자에 몇 가지 문제가있을 것으로 예상됩니다. –

+0

감사! 마지막에 \를 추가해야하는 것처럼 보입니다. \\ ServerAddress \ PDFs \ – user1342164

답변

2

사용 Path.Combine, 당신은 백 슬래시를 누락 문자열을 연결할 때 문자.

Dim Doc1 As New Document 
    Dim path As String = "\\ServerAddress\PDFs" 
    Dim myUniqueFileName = String.Format("{0}.pdf", Guid.NewGuid()) 
    PdfWriter.GetInstance(Doc1, New FileStream(System.IO.Path.Combine(path,myUniqueFileName), FileMode.Create)) 
    Doc1.Open() 
    Dim test As String 
    test = Session("PDF") 
    Doc1.Add(New Paragraph(test)) 

    Doc1.Close() 
관련 문제