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

http://maps.google.com/maps?saddr=startadd&daddr=endaddr

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.
Posted
Updated 13-Sep-11 19:33pm
v2
Comments
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 :
C#
string url = "http://google.com";
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
    sr.Close();
}

// Display results to a webpage
Response.Write(strResult);


Solution 2 :
C#
System.Net.WebClient webClient = new System.Net.WebClient();
webClient.DownloadFile("http://www.dotnetspider.com/index.aspx","C:\\spider.html");


Check this link for full code[^]

Hope this helps.
All the best.
 
Share this answer
 
Comments
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