0
我想設置一個頁面,將允許用戶瀏覽Web服務器上的文件目錄。樹視圖文件到Web地址而不是目錄地址
其目的是允許用戶將文件放在給定的目錄結構中,代碼將根據目錄創建樹視圖。
當設置節點導航URL時,它將映射到C:\ Staging \ Files文件,該文件在Web上不起作用。我需要映射到http://webaddress/staging/files等
這裏是有問題的代碼
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
'
Dim rootDir As New DirectoryInfo("C:\Staging\")
' Enter the RecurseNodes function to recursively walk the directory tree.
Dim RootNode As TreeNode = RecurseNodes(rootDir)
' Add this Node hierarchy to the TreeNode control.
Treeview1.Nodes.Add(RootNode)
End If
End Sub
Private Function RecurseNodes(ByVal thisDir As DirectoryInfo) As TreeNode
Dim thisDirNode As New TreeNode(thisDir.Name, Nothing)
' Get all the subdirectories in this Directory.
Dim subDirs As DirectoryInfo() = thisDir.GetDirectories()
For Each subDir As DirectoryInfo In subDirs
thisDirNode.ChildNodes.Add(RecurseNodes(subDir))
Next
' Now get the files in this Directory.
Dim files As FileInfo() = thisDir.GetFiles()
For Each file As FileInfo In files
Dim thisFileNode As New TreeNode(file.Name, Nothing)
**thisFileNode.NavigateUrl = file.FullName**
thisDirNode.ChildNodes.Add(thisFileNode)
Next
Return thisDirNode
End Function
可不可以給我這是如何工作的例子嗎? – 2009-07-12 15:35:37