Click here to Skip to main content
15,888,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
I need to read a text file from the local folder in my machine through a web application, but it always maps to server path. Is there any way to locate to my local machine instead of Server path. I am using vb with asp.net. Please Help.

{

strlocaldir = "C:\RJ\textfile.txt"
        If File.Exists("strlocaldir") Then
            lblsysdir.Text &= "File exists :) " & strlocaldir
            '.......perform read operation
        Else
            lblsysdir.Text &= "File does not exists :( " & strlocaldir
            'Exit out
        End If
}
Posted

1 solution

1.In any web application you have no direct access to any files outside the web application execution folder, so there is no way do do like you wanted!

2.One solution is to implement a WCF (Windows Communication Foundation) service, than to install this service on your local computer and this service can have access to any files from your local server; and finally your web application will communicate with this WCF service in order to access the files.
 
Share this answer
 
Comments
[no name] 5-Dec-14 3:41am    
Thanks Raul. But if that is not possible then how does file upload control works(maps to our local path)?
Raul Iloc 5-Dec-14 3:46am    
The upload control is using the browser to access the file from the client, then the file is send by the browser to the web application that is running on the web server (that could be far away over the internet).
[no name] 5-Dec-14 4:18am    
Yea, the same way can we access the client file through the web application?
Raul Iloc 5-Dec-14 4:24am    
You should clearly understand that your web application (like any other web application) is running on the web server, the web server is far way over the internet, and the users of the web applications are using the web browsers, and each web browser is a client that is running on the user PC and communicate over the internet with the web server. Because the web browser is running on user PC it has access to user files, but the web application (from the web server) is cannot do that!

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