Programatically find the pages in a project

M

Milsnips

Can anyone help out on this one?

i would like to find out all the ASPX and ASCX pages that are in my project,
and return them in an arraylist.

thanks,
Paul.
 
M

Marina

You would have to load the assembly, and using reflection go through each
class to see if it inherits from Page or UserControl. If it does, add it to
your list of class names.
 
K

Karl Seguin

Well, you could recursively loop through the directory structure looking for
said files. something like:

Public Sub GetFiles(ByVal path As String, ByVal extension As String, ByVal
files As ArrayList)
For Each file As String In System.IO.Directory.GetFiles(path, extension)
files.Add(file)
Next
For Each directory As String In System.IO.Directory.GetDirectories(path)
GetFiles(directory, extension, files)
Next
End Sub

and you can use it via:

Dim files As New ArrayList
GetFiles(Server.MapPath("~"), "*.aspx", files)


Karl
 
M

Milsnips

thanks for the info,

how do i actually reference the assembly name/string in the assembly.Load
function? is it the DLL name?

regards,
Paul.
 
M

Marina

It depends on where that DLL is, etc. Look at the Assembly class's load
method that can load a specified assembly into memory.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,234
Latest member
SkyeWeems

Latest Threads

Top