Answered by:
Unable to View file

Question
-
User-797751191 posted
Hi
I have application installed in c:\inetpub\wwwroot . I am accessing application with below Url . 202.10.10.121 is the Public Id. Local Id is 192,168,1,12 on which IIS Server is installed.
Http://202.10.10.121/Tmp/Index.aspx.
I am able to save file with below code i another drive
string Path = @"e:\Doc\" + filename;
What should be the Url to view the file.
Thanks
Monday, February 4, 2019 2:48 PM
Answers
-
User-1174608757 posted
Hi jsshivalik,
Now i want to open file which i am not able to do.If you want to show file just by enter the url, you should use Response.WriteFile(filePath) in page load event. For example if the file you want to show is a pdf file , you could write as blow:
in pageload:
protected void Page_Load(object sender, EventArgs e) { Response.Clear(); string filePath = @"e:\Doc\" + filename;// enter the address of file Response.ContentType = "application/pdf";// alert the type of file Response.WriteFile(filePath);//show Response.End(); }
Then you could directly enter the url of aspx which you want to show the file. I hope it could help you.
Best Regards
Wei Zhang
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, February 6, 2019 6:30 AM
All replies
-
User1724605321 posted
Hi jsshivalik ,
In your application you can grant permissions for your folder to the application pool , so that your application could access other local disk drive . But i don't think you could directly view the file by entering the url in browser's address bar .
Best Regards,
Nan Yu
Tuesday, February 5, 2019 2:46 AM -
User409696431 posted
The file is not being saved in a folder inside your site, so there is no URL to it. If you can map the folder you are saving the file in to a virtual directory inside your site, you could then access it with a URL in your site. (Of course the easiest thing would be to save the files to a folder inside your site in the first place, if you intend to make them visible to your site visitors.)
Tuesday, February 5, 2019 2:53 AM -
User-797751191 posted
Hi
Since i am able to save file , there must be some way to view also
Thanks
Tuesday, February 5, 2019 4:42 AM -
User-797751191 posted
Hi Kathy
If Website is in d:\test. I want to save file in d:\Doc which is not in Website folder . How i can save the file in Doc and then View the file
Thanks
Tuesday, February 5, 2019 9:18 AM -
User409696431 posted
I told you in my earlier reply. Map d:\Doc to a virtual folder inside your website, so you can link to it.
Tuesday, February 5, 2019 9:43 PM -
User-1174608757 posted
Hi jsshivalik,
According to your description,if you want to view file which is not in Website folder, you could set the permission of folder that it could be write and read. You could follow the steps as below I hope it could help you. .
1.In Windows Explorer, right-click the folder whose permissions you want to change, and then click Properties.
2.Click the Security tab.
3.Add Authenticated Users and give them Full Control.
4.Click Advanced.
5.In the Advanced Security Settings dialog box, click Enable inheritance.it shows as below:
Best Regards
Wei Zhang
Wednesday, February 6, 2019 2:22 AM -
User-797751191 posted
Hi Wei
I am able to Save file in that folder. Now i want to open file which i am not able to do.
Thanks
Wednesday, February 6, 2019 5:14 AM -
User-1174608757 posted
Hi jsshivalik,
Now i want to open file which i am not able to do.If you want to show file just by enter the url, you should use Response.WriteFile(filePath) in page load event. For example if the file you want to show is a pdf file , you could write as blow:
in pageload:
protected void Page_Load(object sender, EventArgs e) { Response.Clear(); string filePath = @"e:\Doc\" + filename;// enter the address of file Response.ContentType = "application/pdf";// alert the type of file Response.WriteFile(filePath);//show Response.End(); }
Then you could directly enter the url of aspx which you want to show the file. I hope it could help you.
Best Regards
Wei Zhang
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, February 6, 2019 6:30 AM