Displaying the Files in a Directory
Public doc As String = “..\Data\”
Protected Sub ddlFolder1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlFolder1.SelectedIndexChanged
Dim filePath As String = Server.MapPath(doc + Me.ddlFolder1.SelectedValue + “\”)
Dim dirInfo As New DirectoryInfo(filePath)
Me.ddlFolder2.DataSource = dirInfo.GetDirectories()
Me.ddlFolder2.DataBind()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim filePath As String = Server.MapPath(doc)
Dim dirInfo As New DirectoryInfo(filePath)
Me.ddlFolder1.DataSource = dirInfo.GetDirectories()
Me.ddlFolder1.DataBind()
End If
End Sub
Protected Sub ddlFolder2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlFolder2.SelectedIndexChanged
Dim filePath As String = Server.MapPath(doc + Me.ddlFolder1.SelectedValue + “\” + Me.ddlFolder2.SelectedValue + “\”)
Dim dirInfo As New DirectoryInfo(filePath)
Me.dlList.DataSource = dirInfo.GetFiles(”*.shp”)
Me.dlList.DataBind()
Me.ddlfiles.DataSource = dirInfo.GetFiles(”*.shp”)
Me.ddlfiles.DataBind()
End Sub
留言列表