Click here to Skip to main content
15,351,370 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear all

In windows form application I can get an executable file's path by "Path.Combine(Application.StartupPath, "xxx.xxx")". I wonder if I want to get a aspx file's path, is there any API I can call?

Thank you.
Posted
Updated 4-Oct-11 15:51pm
v3

This code is working check it once

C#
 DirectoryInfo dirInfo = new DirectoryInfo(Server.MapPath(""));

FileInfo[] str = dirInfo.GetFiles("*.aspx");
   
Comments
Roger Chao 5-Oct-11 4:46am
   
Thank you for your help.
P.Salini 5-Oct-11 5:40am
   
u r welcome.
Hi Please find the solution here....

XML
<%@ Import Namespace="System.IO" %>
<script language="VB" runat="server">
  Sub Page_Load(sender as Object, e as EventArgs)
    Dim dirInfo as New DirectoryInfo(Server.MapPath(""))

    articleList.DataSource = dirInfo.GetFiles("*.aspx")
    articleList.DataBind()
  End Sub
</script>


<asp:DataGrid runat="server" id="articleList" Font-Name="Verdana"
    AutoGenerateColumns="False" AlternatingItemStyle-BackColor="#eeeeee"
    HeaderStyle-BackColor="Navy" HeaderStyle-ForeColor="White"
    HeaderStyle-Font-Size="15pt" HeaderStyle-Font-Bold="True">
  <Columns>
    <asp:HyperLinkColumn DataNavigateUrlField="Name" DataTextField="Name" HeaderText="File Name" />
    <asp:BoundColumn DataField="LastWriteTime" HeaderText="Last Write Time"
        ItemStyle-HorizontalAlign="Center" DataFormatString="{0:d}" />
    <asp:BoundColumn DataField="Length" HeaderText="File Size"
        ItemStyle-HorizontalAlign="Right" DataFormatString="{0:#,### bytes}" />
  </Columns>
</asp:DataGrid>


Thanks
Murugan
   
Comments
Roger Chao 5-Oct-11 4:46am
   
Sorry I'm not a VB guy, by still thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900