Solved

What is the best way to get a tiny string from a remote server?

Posted on 2007-11-18
3
314 Views
Last Modified: 2013-12-17
Hi,

I have a URL that shows UNIX date format. Something link this: 1192763425. The URL only contains this number, nothing extra.

I want to get this number into a string to use it in my C# desktop application.

What is the fastest and most efficient way to accomplish this task?

Please advise.
0
Comment
Question by:EEssam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
Munawar Hussain earned 500 total points
ID: 20309835
Though not sure if it is exactly what you want.
you can get contents of any site using httpRequest and httpResponse to specific URL
here is the way... thanks
using System;   
using System.IO;   
using System.Net;   
using System.Text;   
  
// Create the web request   
HttpWebRequest request = WebRequest.Create("http://www.mysite.com/") as HttpWebRequest;   
  
// Get response   
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)   
{   
    // Get the response stream   
    StreamReader reader = new StreamReader(response.GetResponseStream());   
  
    // Console application output   
    Console.WriteLine(reader.ReadToEnd());   
}   

Open in new window

0
 

Author Comment

by:EEssam
ID: 20309885
It worked but as I stated I'm looking for the fastest and most efficient way. Why I do not use something like this:
string address = "http://www.somedomain.com/somefile.ext";
System.Net.WebClient client = new System.Net.WebClient ();
string reply = client.DownloadString (address);

Open in new window

0
 
LVL 12

Expert Comment

by:Munawar Hussain
ID: 20311132
sure.. there are options.. but you need to select the one best match your requirements.
thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question