Inherits System.Web.UI.Page Dim conTextBox(1000) As System.Web.UI.WebControls.TextBox ' TextBoxの数 Dim conLiteral(1000) As System.Web.UI.WebControls.Literal Protected Sub Button2_Click(sender As Object, e As System.EventArgs) Handles Button2.Click Dim namae(10) As String Dim icount As Integer = 1 Dim MenuBtn(500) As System.Web.UI.WebControls.Button 'ファイルをすべて取得する Dim di As New System.IO.DirectoryInfo("d:\d\open\test") '表示させるフォルダの場所を指定 Dim files As System.IO.FileInfo() = _ di.GetFiles("*.*", System.IO.SearchOption.TopDirectoryOnly) Dim subFolders As System.IO.DirectoryInfo() = _ di.GetDirectories("*", System.IO.SearchOption.AllDirectories) 'サブフォルダー名ボタン作成 For Each subFolder As System.IO.DirectoryInfo In subFolders Dim tbRow1 As New TableRow Dim tbCell As New TableCell conTextBox(icount) = New System.Web.UI.WebControls.TextBox conTextBox(icount).BorderStyle = BorderStyle.None conTextBox(icount).Width = System.Web.UI.WebControls.Unit.Parse("20px") MenuBtn(icount) = New System.Web.UI.WebControls.Button tbCell.Controls.Add(conTextBox(icount)) conTextBox(icount).Text = icount MenuBtn(icount).Text = subFolder.Name AddHandler MenuBtn(icount).Click, AddressOf btn_Click tbCell.Controls.Add(MenuBtn(icount)) tbRow1.Cells.Add(tbCell) Table1.Rows.Add(tbRow1) icount = icount + 1 Next 'ファイル名を表示 For Each f As System.IO.FileInfo In files Dim tbRow2 As New TableRow Dim tbCell As New TableCell conLiteral(icount) = New System.Web.UI.WebControls.Literal conTextBox(icount) = New System.Web.UI.WebControls.TextBox conTextBox(icount).BorderStyle = BorderStyle.None conTextBox(icount).Width = System.Web.UI.WebControls.Unit.Parse("20px") tbCell.Controls.Add(conTextBox(icount)) conTextBox(icount).Text = icount tbRow2.Cells.Add(tbCell) namae(1) = "/open/test/" & f.Name 'ブラウザから表示する場所を指定 namae(2) = f.Name conLiteral(icount).Text = "<A href=""" & namae(1) & """>" & namae(2) & "</a><BR>" tbCell.Controls.Add(conLiteral(icount)) tbRow2.Cells.Add(tbCell) Table1.Rows.Add(tbRow2) icount = icount + 1 Next End Sub Private Sub btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim failenam As String = CType(sender, Button).Text Dim namae(10) As String Dim icount As Integer = 1 Dim MenuBtn(500) As System.Web.UI.WebControls.Button 'ファイルをすべて取得する Dim di As New System.IO.DirectoryInfo("d:\d\open\test\" & failenam) '表示させるフォルダの場所を指定 Dim files As System.IO.FileInfo() = _ di.GetFiles("*.*", System.IO.SearchOption.TopDirectoryOnly) 'ファイル名を表示 '省略 End Sub End Class