I am trying to set up a page that will allow the user to browse a file directory on the Web server.
The aim is to allow users to drop files within a given directory structure and the code will create the tree view based off the directory.
When setting the Nodes Navigate URL it maps to the C:\Staging\Files which obvioulsy does not work on the web. I would need to map to http://webaddress/staging/files etc
Here is the offending code
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