Note that there are some explanatory texts on larger screens.

plurals
  1. POTreeview map file to Web address rather than directory address
    text
    copied!<p>I am trying to set up a page that will allow the user to browse a file directory on the Web server.</p> <p>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.</p> <p>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 <a href="http://webaddress/staging/files" rel="nofollow noreferrer">http://webaddress/staging/files</a> etc</p> <p>Here is the offending code</p> <pre><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 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload