Unable to open CSV file from website
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/8461050/unable-to-open-csv-file-from-internet-using-c-sharp">Unable to open CSV file from internet using C#</a>  </p>
</blockquote>



<p>I wrote this code to open and parse a CSV file. It works when I open the file from a folder on my hard drive. I changed the code on lines 24 - 26 to open the file from a website.
I'm getting the error message <strong>"URI formats are not supported"</strong> from Line 27 of attached code. I can open the file using VBA.</p>

<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            //
            // Read in a file line-by-line, and store it all in a List.
            //
            int i = 0;
            DateTime dte;
            List&lt;string&gt; list = new List&lt;string&gt;();
            float[] Prices = new float[4];

            WebClient wc = new WebClient();

            byte[] data = wc.DownloadData("http://www.datasource.com/apps/qt/csv/pricehistory.ac?section=yearly_price_download&amp;code=XXX");

            using (StreamReader reader = new StreamReader(wc))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    //list.Add(line); // Add to list.
                    Console.WriteLine(line); // Write to console.

                    string[] parts = line.Split(',');
                    int DateSetter = 1;
                    int DateDone = 0;
                    int CountFloat = 0;
                    int PricesDone = 0;
                    Double Volume = 0;

                    foreach (string part in parts)
                    {
                        Console.WriteLine("{0} : {1}", i, part);

                        if (DateSetter == 1)
                        {
                            dte = DateTime.Parse(part);
                            DateSetter = 2;
                            Console.WriteLine(dte);
                        }
                        if (DateDone == 1)
                        {
                            if (DateSetter &lt; 6)
                            {
                                Prices[CountFloat] = float.Parse(part);
                                CountFloat++;
                                DateSetter++;
                                Console.WriteLine(Prices[3]);
                            } 
                        }
                        DateDone = 1;
                        if (PricesDone == 1)
                        {
                            Volume = double.Parse(part);
                            Console.WriteLine(Volume);
                        }
                        if (DateSetter == 6)
                        {
                            PricesDone = 1;
                        }
                    }



            }
       }
        Console.ReadLine();
    }
}
</code></pre>

<p>}</p>
