Click here to Skip to main content
15,906,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I thought of working on distace calculation of routes for a small application, and i came up wit an idea to use google maps for that, I can use the url as

but inorder to access in my application i thought of saving the page in text format, i can do it using File->Save AS tab,
how can i do it throug the code.

pls help.
Updated 13-Sep-11 19:33pm
rkthiyagarajan 14-Sep-11 1:29am    
I didn't understand your question so please explain your question
Thiagarajan Duraisamy 14-Sep-11 2:25am    
u can use google maps to get the distance and routes between two points right, and when u save tat result page as a text file your output is copied as a in text, for my application i am trying to get this info of distance to store it in database, a new user can search for two locations and tat gets added into the db.
i want the code behind logic to save the result into the text format,
i am actually sending the url through my page.

1 solution

There are two ways to do so :

Solution 1 :
string url = "";
string strResult = "";
WebResponse objResponse;
WebRequest objRequest = System.Net.HttpWebRequest.Create(url);

//Get the Web Page data
objResponse = objRequest.GetResponse();

using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
    //Read the data
    strResult = sr.ReadToEnd();

    // Close and clean up the StreamReader

// Display results to a webpage

Solution 2 :
System.Net.WebClient webClient = new System.Net.WebClient();

Check this link for full code[^]

Hope this helps.
All the best.
Share this answer
Thiagarajan Duraisamy 14-Sep-11 2:26am    
its not working, getting an exceptin as request timed out.
Pravin Patil, Mumbai 23-Sep-11 13:18pm    
Try to set the credentials for the given URL, may be you are missing credentials....

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