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;
fs = File.Open(Path, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
bool canRead = fs.CanRead;
Response.Write("<script>window.open('file:" + Path.Replace("\\", "/") + "')'</script>");
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.When the page opens i only see the blank page opened with no pdf document opened.
2) In the else loop if the document doesnot exist then i need to display the message and close the current page.