以下のコードを使用してpdfを生成しています。次に、生成されたばかりの PDF をユーザーがクリックできるように、グリッドビューを設定します。例外メッセージが表示されます:Exception type: IOException
別のプロセスで使用されているため、プロセスはファイル '\Server\PDFs\PE10091026-Rev.pdf' にアクセスできません。
別の PDF を生成すると、前の PDF を開くことができます。
誰もファイルを開いていない場合、何がロックを保持しているのか分かりますか?
Dim Doc1 As New Document
Dim path As String = "\\server\PDFs\"
Dim myUniqueFileName = String.Format("{0}.pdf", Session("FileName") & "-Rev")
Dim pdfWrite As PdfWriter = PdfWriter.GetInstance(Doc1, New FileStream(path & myUniqueFileName, FileMode.Create))
Doc1.Open()
Dim test As String
test = Session("PDF")
Dim PDFHeader As String
PDFHeader = Session("Header")
Dim imagepath As String = Server.MapPath(".") & "/images/Header.png"
Dim image As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(imagepath)
image.ScalePercent(70.0F)
Dim line1 As New iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, BaseColor.BLACK, Element.ALIGN_LEFT, 1)
Doc1.Add(image)
Doc1.Add(New Paragraph(PDFHeader))
Doc1.Add(New Chunk(line1))
Doc1.Add(New Paragraph(test))
Doc1.Close()
Doc1.Dispose()