- Download the RSS feeds from Youtube using their API
Convert the RSS feeds into Xlobby readable XML database by applying XSL transform
I have most of the pieces working but having strange problems with writing the full content of RSS feeds into a file. Here is the simplified relevant code
- Code: Select all
try
{
HttpWebRequest myreq = (HttpWebRequest)WebRequest.Create("http://youtube.com/rss/global/top_viewed_today.rss");
HttpWebResponse myrep = (HttpWebResponse)myreq.GetResponse();
StreamReader mystream = new StreamReader(myrep.GetResponseStream(), Encoding.UTF8);
string outputstring;
outputstring = mystream.ReadToEnd();
FileStream fs = new FileStream("temp.txt", FileMode.Create, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs);
sw.Write(outputstring);
//Console.WriteLine(outputstring);
}
The problem is that when I try to write the RSS webstream to file "temp.txt", it does not write the full feed to the file. Several lines are missing at the end.
On the other hand, if I dump the outputstring to the console (as seen in the commented line in the above code), I can see the whole stream.
I cannot understand this. Can someone please help ?