Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Problems with carret in URL (real time ticker sample)

Reply
 
Old 05-15-2009   #1 (permalink)
Mikeerh


 
 

Problems with carret in URL (real time ticker sample)

I have a ticker sample running with yahoo as provider.
When it comes to indices they all start with a caret (^) like ^DJI.
The framework converts this string internally into a %% before it is on the
net (I saw it with wireshark) and than yahoo responds with a N/A ??
How can I get the framework to let the carret through??

here is the sample code:

?using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;

namespace YahooTicker
{
class Program
{


private static void Main(string[] args)
{
string ticker = "^DJI";
Uri siteUri = new Uri("http://quote.yahoo.com/d/quotes.csv?s=" +
ticker + "&f=sl1d1t1c1ohgvj1pp2owern&e=.csv");

WebClient web = new WebClient();
string data = web.DownloadString(siteUri);

Quote q = Quote.Parse(data);

Console.WriteLine(string.Format("{0} {1} Last:{2} Change:{3}
Bid:{4} Offer: {5}", q.Ticker, q.Name, q.Last, q.Change, q.Bid, q.Offer));
Console.ReadLine();
}
}

public class Quote
{
public double Last { get; set; }
public string Ticker { get; set; }
public double Change { get; set; }
public string Name { get; set; }
public double Bid { get; set; }
public double Offer { get; set; }

public static Quote Parse(string data)
{
string[] fields = data.Replace("\"", "").Split(',');
Quote q = new Quote
{
Ticker = fields[0].ToUpper(),
Last = Convert.ToDouble(fields[1]),
Change = Convert.ToDouble(fields[4]),
Bid = Convert.ToDouble(fields[5]),
Offer = Convert.ToDouble(fields[6]),
Name = fields[7].ToUpper()
};

return q;
}
}



My System SpecsSystem Spec
Old 05-15-2009   #2 (permalink)
Andrew Morton


 
 

Re: Problems with carret in URL (real time ticker sample)

Mikeerh wrote:
Quote:

> I have a ticker sample running with yahoo as provider.
> When it comes to indices they all start with a caret (^) like ^DJI.
> The framework converts this string internally into a %% before it is
> on the net (I saw it with wireshark) and than yahoo responds with a
> N/A ?? How can I get the framework to let the carret through??
>
> here is the sample code:
Quote:

> string ticker = "^DJI";
> Uri siteUri = new Uri("http://quote.yahoo.com/d/quotes.csv?s=" + ticker +
> "&f=sl1d1t1c1ohgvj1pp2owern&e=.csv");
Have you tried ... + Server.UrlEncode(ticker) + ...?

Andrew


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Script: change in real time the key in the registry VB Script
C#.NET Interview Questions And Real Time Discussions .NET General
Real-World Sample Application? .NET General
Real time command line spy PowerShell
How to turn on CA EZ Antivirus real-time? Vista security


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46