Solved

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

Posted on 2007-11-18
3
264 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
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
needo_jee 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:needo_jee
ID: 20311132
sure.. there are options.. but you need to select the one best match your requirements.
thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now