Reponse.WriteFile Issue
-
Hi, I have a file in other computer say (\\10.10.10.10\\sharedFolder\abc.txt) and asp.net is running on local computer Can I use Response.WriteFile to server this file when client requested. Response.WriteFile("\\10.10.10.10\\sharedFolder\abc.txt"); But I am getting an exception saying file does not exists at location : c:\\inetpub\\wwwroot\\10.10.10.10\\sharedFolder\abc.txt Please let me know how we can do this. Thanks,
-
Hi, I have a file in other computer say (\\10.10.10.10\\sharedFolder\abc.txt) and asp.net is running on local computer Can I use Response.WriteFile to server this file when client requested. Response.WriteFile("\\10.10.10.10\\sharedFolder\abc.txt"); But I am getting an exception saying file does not exists at location : c:\\inetpub\\wwwroot\\10.10.10.10\\sharedFolder\abc.txt Please let me know how we can do this. Thanks,
It is not a good practice to access the file system except your application root from a web application. If you should then you need to use a user credential with a elevated access rights than the default IIS user. Server admins won't let you do that. BTW,
Response.WriteFile
does not read a file, it writes the response to the file on the current execution directory. To really write into a file you need to use File objects. Do you want to write data into the file or read the file and display the data to your users on your application? -
Hi, I have a file in other computer say (\\10.10.10.10\\sharedFolder\abc.txt) and asp.net is running on local computer Can I use Response.WriteFile to server this file when client requested. Response.WriteFile("\\10.10.10.10\\sharedFolder\abc.txt"); But I am getting an exception saying file does not exists at location : c:\\inetpub\\wwwroot\\10.10.10.10\\sharedFolder\abc.txt Please let me know how we can do this. Thanks,
Try using following if the file is on the same server
Response.WriteFile("~\\sharedFolder\abc.txt");
Or use following if the file is not on the same server
Response.WriteFile(@"http://10.10.10.10/sharedFolder/abc.txt");