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()
4

1 回答 1

1

使用 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()
于 2013-07-16T20:16:05.797 回答