TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
karthik v
NA
109
70.9k
Open a pdf document in a aspx page
Nov 23 2011 10:48 AM
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??????????
Reply
Answers (
4
)
how to get Client System name On WAN
Profile in asp.net