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
Solved

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

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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

791 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