Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2007-11-18
3
Medium Priority
?
335 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:
Munawar Hussain earned 2000 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

885 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