[dba-VB] Open PDF file

James Barash James at fcidms.com
Mon Nov 26 10:30:30 CST 2007


David:

How are you displaying the list of files? I do something similar using an
ASP.Net table and adding the filenames as cells with a hyperlink to the
appropiate file on the server. It is the client that needs to have Adobe
installed, not the server since it is the client that renders the file. 
Below is the code. It loops through all the files in a specified directory.
For each file you create a new row in the table, create a new cell, set the
cell text to a clickable hyperlink to the appropriate file and add the row
to the ASP.net table. The directories are all relative to the root directory
of the website. The pfd files open in a new browser window. If the client
does not have Adobe installed, they should get the option of saving the file
locally.

Hope this helps.

James Barash

Dim root As String = Server.MapPath(".") & "/" & strDir
Dim files() As String
files = System.IO.Directory.GetFiles(root, "*")
Dim strFilename As String, f as String
Table1.Rows.Clear()
For Each f In files
strFilename = System.IO.Path.GetFileName(f)
row = New Web.UI.WebControls.TableRow
cell = New Web.UI.WebControls.TableCell
cell.Text = "<a href=""" & "./" & strDir & "/" & strFilename & """
target=""_blank"" >" & strFilename & "</a>"
row.Cells.Add(cell)
Table1.Rows.Add(row)
Next f




-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of David Emerson
Sent: Monday, November 26, 2007 12:15 AM
To: dba-vb at databaseadvisors.com
Subject: [dba-VB] Open PDF file

I am using VS 2005 and VB.Net for a web site.

I have a number of PDF files that are stored in a static folder on the
server.

Users select from a list on files on a web page and I want to open 
the files in Adobe.  Adobe reader is installed on the server.

Can anyone give me a pointer to how I can take a string with path and 
file name, and open it?

Regards

David Emerson
Dalyn Software Ltd
Wellington, New Zealand 

_______________________________________________
dba-VB mailing list
dba-VB at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-vb
http://www.databaseadvisors.com




More information about the dba-VB mailing list