This Demo Shows a List of Files from the /demos Directory

This demo illustrates binding the results from the DirectoryInfo.GetFiles() method to a DataGrid.


File NameLast Write TimeFile Size
ArraySortingDemo.aspx12/10/20072,410 bytes
BinarySearch.complex.aspx12/10/20075,239 bytes
BinarySearch.simple.aspx12/10/20074,231 bytes
BindArrayDG.aspx12/10/20071,569 bytes
BindArrayDL.aspx12/10/20071,734 bytes
BindCustomClass.aspx12/10/20073,410 bytes
BindingDataGrid.aspx12/10/20073,492 bytes
blogTest.aspx12/10/20074,203 bytes
BrowserDetection.aspx12/10/20074,162 bytes
ButtonClientSide.aspx12/10/20071,546 bytes
CachedPaging.aspx12/10/20077,734 bytes
Calendar.aspx12/10/20071,583 bytes
Cal_1.aspx12/10/20071,282 bytes
Cal_2.aspx12/10/20074,507 bytes
Cal_3.aspx12/10/20077,315 bytes
CheckboxListDemo.aspx12/10/20077,541 bytes
CollapsibleRepeater.aspx12/10/20075,367 bytes
ConsumeRSS.aspx12/10/20074,681 bytes
csharpexample.aspx12/10/20073,239 bytes
customizeTemplate.aspx12/10/20074,447 bytes
CustPaging.aspx12/20/20075,695 bytes
DataTableCompute.aspx12/10/20074,016 bytes
DataTableExpression.aspx12/10/20072,704 bytes
ddlSelectedItemStyle.aspx12/10/20071,161 bytes
dgExample1.aspx12/10/20072,088 bytes
dgExample10.aspx12/10/20073,532 bytes
dgExample11.aspx12/10/20076,699 bytes
dgExample12.aspx12/10/20075,053 bytes
dgExample13.aspx12/10/20074,150 bytes
dgExample14.aspx12/10/20075,571 bytes
dgExample15.aspx12/10/20077,483 bytes
dgExample16.aspx12/10/20078,157 bytes
dgExample17.aspx12/10/200710,891 bytes
dgExample18.aspx12/10/20075,410 bytes
dgExample19.aspx12/10/20075,718 bytes
dgExample2.aspx12/10/20072,479 bytes
dgExample20.aspx12/10/20077,405 bytes
dgExample21.aspx12/10/20077,642 bytes
dgExample22.aspx12/10/20077,919 bytes
dgExample23.aspx12/10/20075,638 bytes
dgExample24.aspx12/10/20075,203 bytes
dgExample25.aspx12/10/20074,311 bytes
dgExample26.aspx12/10/20074,970 bytes
dgExample27.aspx12/10/20077,201 bytes
dgExample28.aspx12/10/20075,059 bytes
dgExample29.aspx12/10/20073,590 bytes
dgExample3.aspx12/10/20072,884 bytes
dgExample30.aspx12/10/20072,901 bytes
dgExample31.aspx12/10/20073,557 bytes
dgExample32.aspx12/10/20073,858 bytes
dgExample33.aspx12/10/20073,713 bytes
dgExample34.aspx12/10/20075,349 bytes
dgExample35.aspx12/10/20076,619 bytes
dgExample36.aspx12/10/20077,815 bytes
dgExample37.aspx12/10/20079,272 bytes
dgExample4.aspx12/10/20074,210 bytes
dgExample5.aspx12/10/20073,689 bytes
dgExample6.aspx12/10/20074,437 bytes
dgExample7.aspx12/10/20075,550 bytes
dgExample8.aspx12/10/20077,961 bytes
dgExample9.aspx12/10/20075,448 bytes
dgHighlight.aspx12/10/20078,357 bytes
dgRandomOrder.aspx12/10/20073,499 bytes
dgRandomOrder2.aspx12/10/20074,929 bytes
dgRollup.aspx12/10/200710,767 bytes
dgSubHeaders.aspx12/10/20077,471 bytes
dgSummaryDemo.aspx12/10/20072,526 bytes
DHTMLDataGrid.aspx12/10/20071,126 bytes
DispImagesFromDir.aspx12/10/20072,529 bytes
DispImagesFromDirWithResize.aspx12/10/20074,594 bytes
DispImagesFromDirWithResize2.aspx12/10/20075,742 bytes
DisplayXMLInASPNET.aspx12/10/20071,048 bytes
dlExampleRepeatColumns.aspx12/10/20073,258 bytes
DynamicDataTable.aspx12/10/20072,340 bytes
dynCtrls1.aspx12/10/20071,140 bytes
dynCtrls2.aspx12/10/20071,956 bytes
dynCtrls3.aspx12/10/20071,734 bytes
dynCtrls4.aspx12/10/20072,527 bytes
dynCtrls5.aspx12/10/20073,727 bytes
EmailControl.aspx12/10/20073,174 bytes
EmailControl2.aspx12/10/20073,573 bytes
EmailControl3.aspx12/10/20072,829 bytes
enc.aspx12/10/20075,478 bytes
ExpiringDemoA.aspx12/10/20076,102 bytes
ExpiringDemoB.aspx12/10/20077,049 bytes
FamilyTree-TreeView.aspx12/10/20073,738 bytes
FileDeptDataCaching.aspx12/10/20074,601 bytes
filesystemdisp.aspx12/10/2007975 bytes
FormatXML.aspx12/10/2007610 bytes
FreeTextBoxDemo1.aspx12/10/20072,441 bytes
FreeTextBoxDemo2.aspx12/10/20072,780 bytes
GeneratePassword.aspx12/10/20078,849 bytes
GetRenderedHTML.aspx12/10/20074,765 bytes
GoogleCache.aspx12/10/2007599 bytes
GoogleSearch.aspx12/10/20072,406 bytes
GoogleSearch.Full.aspx12/10/20076,112 bytes
hangman.aspx12/10/200714,928 bytes
HoverCalInPage.aspx12/10/20071,991 bytes
HttpWebRequestDemo1.aspx12/10/20072,673 bytes
HyperlinkInNewWindow.aspx12/10/20074,084 bytes
HyperlinkInNewWindowWithJavaScript.aspx12/10/20074,144 bytes
HyperlinkTest.aspx12/10/20074,475 bytes
IsPrime.aspx12/10/20074,800 bytes
IsPrime.Client.aspx12/10/20076,026 bytes
ListArticles.AllowDelete.aspx12/10/20075,980 bytes
ListArticles.aspx12/10/20072,550 bytes
ListArticles.Sortable.aspx12/10/20076,350 bytes
ListBoxBinding.aspx12/10/20073,394 bytes
listboxEditDG.aspx12/10/20077,753 bytes
MasterDetail.aspx12/10/20076,995 bytes
md5demo.aspx12/10/20074,165 bytes
NoncollapsibleRepeater.aspx12/10/20073,215 bytes
oneDDLInFooter.aspx12/10/200711,891 bytes
OutputCaching.aspx12/10/2007904 bytes
PagingDataGrid.aspx12/10/20076,432 bytes
PieChart.aspx12/10/20073,309 bytes
PrettyCorners.aspx12/10/20074,104 bytes
PrettyRSSDisplay.aspx12/10/20073,659 bytes
printPage.aspx12/10/20074,361 bytes
printPage_old.aspx12/10/20072,420 bytes
ProblemNotReturningDisabledControls.aspx12/10/20078,703 bytes
rc4decrypt.aspx12/10/20072,960 bytes
rc4encrypt.aspx12/10/20073,399 bytes
ReadFile.aspx12/10/20072,546 bytes
ReadTextFile.aspx12/10/20072,546 bytes
ReceivingPage.aspx12/10/20071,688 bytes
regex.aspx12/10/20078,423 bytes
RegExPCase.aspx12/10/20073,126 bytes
RFVforCB.aspx12/10/20072,623 bytes
RolloverButtonDemo.aspx12/10/20072,374 bytes
RowHighlighter.aspx12/10/20078,393 bytes
RowSelectorDemo.aspx12/10/20072,949 bytes
rsdg.Demo1.aspx12/10/20074,579 bytes
rsdg.Demo2.aspx12/10/20073,850 bytes
rsdg.Demo3.aspx12/10/20073,885 bytes
rsdg.Demo4.aspx12/10/20073,851 bytes
RssFeed.aspx12/10/20073,728 bytes
RssFeed.code.aspx12/10/20073,933 bytes
RssFeedDemo.aspx12/10/20071,444 bytes
RssFeedDemo.stylin.aspx12/10/20072,105 bytes
ScreenScrapeDemo.aspx12/10/20071,834 bytes
ScrollableDataGrid.aspx12/10/20073,976 bytes
ScrollableDataGridFixedHeader.aspx12/10/20075,219 bytes
SendEmail.aspx12/10/20075,893 bytes
SendingPage.aspx12/10/20073,323 bytes
sf.aspx12/10/2007793 bytes
ShowImage.aspx12/10/2007893 bytes
ShowThumbNail.aspx12/10/20071,661 bytes
simp.cal.aspx12/10/2007724 bytes
simpCal.aspx12/10/2007631 bytes
SimpleBoundColumn.aspx12/10/20073,068 bytes
SimpleRSSDisplay.aspx12/10/20072,046 bytes
skmMenu.aspx12/10/20071,637 bytes
skmMenu.horiz.aspx12/10/20071,989 bytes
skmMenu.stylin.aspx12/10/20071,819 bytes
StaticDataTable.aspx12/10/20072,872 bytes
StripSpaceComparison.aspx12/10/20073,040 bytes
StripWhitespace.aspx12/10/2007762 bytes
TabInterface.aspx12/10/200712,285 bytes
TamperProofURLs.A.aspx12/10/20075,274 bytes
TamperProofURLs.B.aspx12/10/20076,812 bytes
TestRepeater.aspx12/10/200710,792 bytes
thu.aspx12/10/20071,699 bytes
thumb.aspx12/10/200716,952 bytes
ToolbarDemo.aspx12/10/20071,384 bytes
TracingDemo.aspx12/10/20078,911 bytes
TreeViewBinding1.aspx12/10/20071,158 bytes
TreeViewXMLDemo.aspx12/10/20071,488 bytes
treeview_bound.aspx12/10/2007452 bytes
twoDDLsInFooter.aspx12/10/200715,415 bytes
ulRepeaterDemo.aspx12/10/20072,788 bytes
UserAgent.aspx12/10/2007950 bytes
UserInfoWriter.2.aspx12/10/20071,326 bytes
UserInfoWriter.aspx12/10/20073,393 bytes
UsingLimitColumn.aspx12/10/20073,714 bytes
UsingTemplateColumn.aspx12/10/20075,331 bytes
WriteTextFile.aspx12/10/20073,145 bytes
xmlDG.aspx12/10/200712,158 bytes
xmlRead.aspx12/10/20073,793 bytes
xmlRead2.aspx12/10/20073,793 bytes
xmlser.aspx12/10/20078,122 bytes
xmlWrite.aspx12/10/20072,859 bytes
XPathDemo.aspx12/10/2007987 bytes
XQueryDemo.aspx12/10/20072,474 bytes


Source Code
<%@ 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>  
  

Return to the article