private static void FindAllBlocksInPath( string physWebAppPath, Dictionary<string, string> list, string folder )
{
// Determine the physical path (it will be something like "C:\blahblahblah\Blocks\" or "C:\blahblahblah\Plugins\")
string physicalPath = string.Format( @"{0}{1}{2}\", physWebAppPath, ( physWebAppPath.EndsWith( @"\" ) ) ? "" : @"\", folder );
// Determine the virtual path (it will be either "~/Blocks/" or "~/Plugins/")
string virtualPath = string.Format( "~/{0}/", folder );
// search for all blocks under the physical path
DirectoryInfo di = new DirectoryInfo( physicalPath );
if ( di.Exists )
{
var allBlockNames = di.GetFiles( "*.ascx", SearchOption.AllDirectories );
string fileName = string.Empty;
// Convert them to virtual file/path: ~/<folder>/foo/bar.ascx
for ( int i = 0; i < allBlockNames.Length; i++ )
{
fileName = allBlockNames[i].FullName.Replace( physicalPath, virtualPath ).Replace( @"\", "/" );
list.Add( fileName, fileName.Replace( virtualPath, string.Empty ) );
}
}
}