// Copyright (c) 2010
// by http://openlightgroup.net/
using System;
using System.Data;
using System.Linq;
using System.Web;
using System.Xml.Linq;
using System.Net.Mail;
using System.Text;
using System.Collections.Generic;
using System.IO;
using System.Web.Security;
namespace SilverlightDebateForum
{
public class Utility
{
#region GetAllFileNames
///
/// Find all files in a directory, and all files within every nested
/// directory.
/// from: http://dotnetperls.com/Content/Recursively-Find-Files.aspx
///
/// The starting directory you want to use.
/// A string array containing all the file names.
public static string[] GetAllFileNames(string baseDir)
{
// Store results in the file results list.
List fileResults = new List();
// Store a stack of our directories.
Stack directoryStack = new Stack();
directoryStack.Push(baseDir);
// While there are directories to process and we don't have too many results
while (directoryStack.Count > 0 && fileResults.Count < 1000)
{
string currentDir = directoryStack.Pop();
// Add all files at this directory.
foreach (string fileName in Directory.GetFiles(currentDir, "*.*"))
{
fileResults.Add(fileName);
}
// Add all directories at this directory.
foreach (string directoryName in Directory.GetDirectories(currentDir))
{
directoryStack.Push(directoryName);
}
}
return fileResults.ToArray();
}
#endregion
}
}