I want to open a file which is saved in my local directory folder in asp.net c#. I have tried filestream like this:
path = TreeView1.SelectedNode.Value.ToString(); // file path (D:\projects\Content\Media\xxxx.PDF )
if (IsPostBack)
{
path = TreeView1.SelectedNode.Value.ToString();
FileInfo fileInfo = new FileInfo(path);
if (fileInfo.Exists)
{
FileStream fileStream = fileInfo.Open(FileMode.Open, FileAccess.Read);
StreamReader reader = new StreamReader(fileStream);
}
}
As per my understanding of your question you are trying open the file means you are trying to launch the file If i am right use this
System.Diagnostics.Process.Start(@"Your_PDF_File_Path");
Edit:Here is an easy option for displaying pdf file in html5.
<embed src="Your_File.pdf" width="800px" height="2100px">
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.