I am writing a web page using ASP.NET and VB.Net that will allow users to download PDF's stored in BLOB format on the database.
My question is, when the user clicks the file, where can I save the file to on the user machine, and how do I clean up the files when the user is done. What I would like to do, is just have the machine prompt the user to open or save the file, and then the user can manage the files. The only way I have come across making this work, is have to specify a file location to create the file, then open the file. I am not sure if the users machine will even let me write the file. Any suggestions will be appreciated.
Dim MyNewFileName As String
Using connection As New SqlConnection(ConnectionString)
Dim MyNewQuery As String
MyNewQuery = "Select FileName from RetroWorkSheet where ModNumber = '" & Me.RadcmbInstructions.SelectedValue & "'"
Dim cmd2 As New System.Data.SqlClient.SqlCommand(MyNewQuery, connection)
MyNewFileName = cmd2.ExecuteScalar
Using command As New SqlCommand("select Retro_worksheet from RetroWorksheet where ModNumber = '" & Me.RadcmbInstructions.SelectedValue & "'", connection)
Dim buffer As Byte() = DirectCast(command.ExecuteScalar(), Byte())
Using fs As New FileStream("c:\" & MyNewFileName, FileMode.Create)
fs.Write(buffer, 0, buffer.Length)
Dim Proc As New System.Diagnostics.Process
Proc.StartInfo.WorkingDirectory = "C:\"
Proc.StartInfo.FileName = MyNewFileName