close

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

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 包爾伯 的頭像
    包爾伯

    人生過程精彩才是重點

    包爾伯 發表在 痞客邦 留言(0) 人氣()