How to get list of all files in the directory

To get the list of aspx files under your app directory: Use namespace System.IO VB.NET Dim dirInfo As New DirectoryInfo(Server.MapPath('')) DataGrid1.DataSource = dirInfo.GetFiles('*.aspx') DataGrid1.DataBind() C# DirectoryInfo dirInfo = new DirectoryInfo(Server.MapPath('')); DataGrid1.DataSource = dirInfo.GetFiles('*.aspx'); DataGrid1.DataBind(); The following aspx code will display the resultant files list in the DataGrid in a proper format: <asp:DataGrid runat='server' id='DataGrid1' AutoGenerateColumns='False'> <Columns> <asp:HyperLinkColumn DataNavigateUrlField='Name' DataTextField='Name' HeaderText='File Name'></asp:HyperLinkColumn> <asp:BoundColumn DataField='LastWriteTime' HeaderText='Last Write Time' DataFormatString='{0:d}'></asp:BoundColumn> <asp:BoundColumn DataField='Length' HeaderText='File Size' DataFormatString='{0:#,### bytes}'></asp:BoundColumn> </Columns> </asp:DataGrid>

What does ‘~’ mean in ASP.NET applications

The tilde (~) in front of URLs means that these URLs point to the root of your web application. Web developers are familiar with using relative paths for all links, including hyperlinks, images, and stylesheets, to be able to move around web pages collectively. In ASP.NET when using User controls the relative paths can be difficult to use. The typical solution to this is to use web-root absolute paths instead here, resulting in the hard-coded sub-directories that are common on ASP.NET sites. The correct solution to this problem is to use app-relative paths instead, which ASP.NET nicely makes possible through the use of the tilde (~) prefix. Instead of <a href=’/UC/Page.aspx’>, use <a href=’~/Page.aspx’ runat=’server’>. The same ~ notation works for images also, as long as you add runat=’server’. There is also a ResolveUrl method that allows you to use ~ in your own code, which is one possible way to get stylesheet paths app-relative. Refer Tilde: Reference the Application Root