Reputation: 63
I made app to create reports and save it as .pdf At mine computer after creating report i use this code to save it as .pdf
Try
My.Computer.FileSystem.WriteAllBytes("C:\" & Form1.TextBox2.Text & "_Report.pdf", ReportViewer1.LocalReport.Render("pdf"), False)
MessageBox.Show("Exported to .pdf file on at location C:\", "Note ", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
End Try
But when i send the application to someone else it won't create this the .pdf on other computer. What is required to be installed ?
Upvotes: 0
Views: 140
Reputation: 26
On modern windows computers normal users don't have the permission to access the "C:\" directory directly. When trying to access it with your code, you get a exception, which is in your example code silently ignored.
A better way is to store the file in the users personal folder. You can use the GetFolderPath method to get it:
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
Upvotes: 1