Thanks for your reply
Yes, I finally figured that out. Also, I had a problem with it loading another root node into the TreeView every time I clicked on a folder. Here's what I wound up with (such as it is; I'm new at this):
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim node As TreeNode = New TreeNode()
node.Value = "C:\Websites\WebProject\ClientArea\PDFs\" & Session("strAcctNo") & "\"
node.Text = "Client " & Session("strAcctNo")
LoadDirectories(node, "C:\Websites\WebProject\ClientArea\PDFs\" & Session("strAcctNo") & "\")
Me.TreeView1.Nodes.Add(node)
End If
End Sub
I had another problem trying to make a HyperLinkField to link to a given file; when I set it to use the FullPath property, it stopped appearing as a link. Something about it not being spec'd as a relative path, I guess. I got some help on that one (thanks to "aki4u" over at ExpertsExchange):
Protected Sub TreeView1_SelectedNodeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.SelectedNodeChanged
Dim directory As System.IO.DirectoryInfo = New System.IO.DirectoryInfo(Me.TreeView1.SelectedNode. Value)
'Me.GridView1.DataSource = directory.GetFiles()
Me.GridView1.DataSource = GetFilesDataTable(directory.GetFiles())
Me.GridView1.DataBind()
End Sub
-----------------------------------------------------------------------
Private Function GetFilesDataTable(ByVal arrFi As IO.FileInfo()) As Data.DataTable
Dim dt As Data.DataTable = New Data.DataTable()
dt.Columns.Add("Name")
dt.Columns.Add("Length")
dt.Columns.Add("LastWriteTime")
dt.Columns.Add("PathToTheFile")
'For Each fi As FileInfo In arrFi
Dim cnt As Integer = 0
For cnt = 0 To arrFi.Length - 1
dt.Rows.Add(dt.NewRow())
dt.Rows(cnt)(0) = arrFi(cnt).Name
dt.Rows(cnt)(1) = arrFi(cnt).Length
dt.Rows(cnt)(2) = arrFi(cnt).LastWriteTime
'dt.Rows(cnt)(3) = arrFi(cnt).FullName
'dt.Rows(cnt)(3) = "\WebProject\ClientArea\" & (Client#) & "\" & (Year()) & "\" & arrFi(cnt).Name
dt.Rows(cnt)(3) = arrFi(cnt).FullName.Substring(11)
Next
Return dt
End Function
-----------------------------------------------------------------------
Then on the GridView:
<asp:HyperLinkField
DataNavigateUrlFields="PathToTheFile"
DataNavigateUrlFormatString="{0}"
DataTextField="Name"
HeaderText="File Name" />
|