goldb.org home

AS OF MAY 2008, THIS BLOG IS NO LONGER BEING UPDATED.
Visit the new blog at: http://coreygoldberg.blogspot.com



 Thursday, December 07, 2006

C# - Read Contents Of A Randomly Selected File

string[] fileList = Directory.GetFiles(@"c:\temp");
Random random = new Random();
string fileName = fileList[random.Next(fileList.Length)];
StreamReader sr = File.OpenText(fileName);
string contents = sr.ReadToEnd();



#    Comments [0] |
Comments are closed.