Solved

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

Posted on 2007-11-18
3
281 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

932 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

10 Experts available now in Live!

Get 1:1 Help Now