Open a pdf document in a aspx page
Hi Experts
I am trying to open a pdf document in a aspx page but i dont know what is the mistake i made in the following code.
string Path = Request.QueryString["Path"];
if (File.Exists(Path.Replace("pdf", "txt")))
{
FileStream fs = null;
try
{
fs = File.Open(Path, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
}
catch (IOException)
{
}
bool canRead = fs.CanRead;
if (canRead)
{
fs.Close();
Response.Write("<script>window.open('file:" + Path.Replace("\\", "/") + "')'</script>");
}
}
else
Response.Write("<script>alert('Document has not been created yet'); </script>");
In the above code there are two problems
1) I could not show the pdf document on the page
2) In the else loop if the document doesnot exist then i need to display the message and close the current page.
Any ideas??????????