I am creating a PDF form in vb.net and saving it to my desktop. The user inputs a name into the textbox and when they click the button the pdf file is created and saved to my desktop.
The issue I am having is that the pdf is being saved like this:
Desktop0001report.pdf
I do not understand why "Desktop" is showing in the front. Is there a way to fix this?
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim pdfdoc As New Document(PageSize.A4, 15, 15, 30, 30)
Dim filename As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + TextBox1.Text + " report.pdf"
Dim file As New FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.ReadWrite)
PdfWriter.GetInstance(pdfdoc, file)
pdfdoc.Open()
FillPDF(pdfdoc)
pdfdoc.Close()
Process.Start(filename)
Catch ex As Exception
MessageBox.Show("PDF could not be generated!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
End Sub
End Class
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…