Click here to Skip to main content
15,884,425 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I have an asp.net web application. I am trying to access files from remote server (on local network) and unfortunately it isn’t working out. Problem is I am not sure if the error is cos the path mentioned isn’t correct or is this a problem with iis7 permissions. I have set <identity impersonate="true"... in web.config file. Below is the code i am trying to access :

C#
Response.AppendHeader("content-disposition", "attachment; filename=" + 
 document.FileName);
 Response.ContentType = document.ContentType;
 String filepath = "\\<server-name>\<shared folder>\file.txt";
 Response.WriteFile(filepath);
 Response.End();


I have tried every possible combination of filepath string. Nothing works. Please help.
Posted
Updated 29-Mar-10 6:53am
v4

have you tried accessing the file from windows explorer with a user with the right credentials? Also, the one mistake I see is you're missing the "@" preceding the string, otherwise, you need to qualify your escapes "\" with more escapes.
 
Share this answer
 
Hi I tried that :

String filepath = @"\\<server-name>\\<shared folder>\\test.txt";


I get the exception:

"Could not find file


'\\\\<server-name>\\<shared folder>\\test.txt'


UPDATE SM: When you put @, you don't use escape sequences! Read books please!
try:
String filepath = @"\\<server-name>\<shared folder>\test.txt";
 
Share this answer
 
v2
AFAIK you can't access a file from network like that. Please read the following article for details.

How to Access Network Files using asp.net[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900