Possible duplicate:
Download an ASP.NET 2.0 aspx page using System.Reflection?
In the following code, I repeat my project and get the file paths for the .aspx pages. How to pass them to a page variable. I tried the following code but did not work. I get the following error message
Invalid cast from 'System.String' to 'System.Web.UI.Page'.
Please help me.
thanks
protected void Page_Load(object sender, EventArgs e) { string[] filePaths = Directory.GetFiles(Server.MapPath("~/"), "*.*", SearchOption.AllDirectories); foreach (string filepath in filePaths) { if (filepath.EndsWith(".aspx")) { Response.Write(filepath + "<br/>"); Page page = (Page)Convert.ChangeType(filepath, typeof(Page)); } } }
dotnet practitioner
source share