
Imports System.IO
Imports Telerik.Web.UI
Partial Public Class uploadfiles
Inherits System.Web.UI.Page
Protected Sub UploadButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles UploadButton.Click
BindResults()
End Sub
Private Sub BindTreeToDirectory(ByVal dirPath As String, ByVal parentNode As RadTreeNode)
Dim dirs As String() = Directory.GetDirectories(dirPath)
Dim s As String
For Each s In dirs
Dim parts As String() = s.Split("\"c)
Dim name As String = parts((parts.Length - 1))
If name <> "Examples" Then
Dim node As New RadTreeNode(name)
node.ImageUrl = "Folder.gif"
node.Value = name
node.Category = "Folder"
parentNode.Nodes.Add(node)
BindTreeToDirectory(s, node)
End If
Next s
Dim files As String() = Directory.GetFiles(dirPath)
Dim fileNAme As String
For Each fileNAme In files
Dim parts As String() = fileNAme.Split("\"c)
Dim name As String = parts((parts.Length - 1))
Dim node As New RadTreeNode(name)
Dim fi As New FileInfo(fileNAme)
node.ImageUrl = "File.gif"
node.Value = fi.Name & "@" & fi.Length.ToString() & "@" & fi.LastWriteTime.ToString()
node.Category = dirPath & "\" & fi.Name
parentNode.Nodes.Add(node)
Next fileNAme
End Sub
Private Sub BindResults()
Dim resultsExist As Boolean = RadUpload1.UploadedFiles.Count > 0
lblNoResults.Visible = Not resultsExist
rptReqults.Visible = resultsExist
If resultsExist Then
rptReqults.DataSource = RadUpload1.UploadedFiles
rptReqults.DataBind()
End If
Dim rootFolder As String = Server.MapPath("~/filefolders/")
Dim rootNode As New RadTreeNode(rootFolder)
RadTree1.Nodes.Clear()
rootNode.Text = "Software"
rootNode.Value = Server.MapPath("~/filefolders/")
rootNode.ImageUrl = "Folder.gif"
rootNode.Category = "Folder"
rootNode.Expanded = True
RadTree1.Nodes.Add(rootNode)
BindTreeToDirectory(rootFolder, rootNode)
Dim uploadnode As RadTreeNode = RadTree1.FindNodeByText("RadTree1.SelectedNode.Text")
uploadnode.Expanded = True
End Sub
Private Sub InitializeComponent()
Dim nd As New DirectoryInfo(Server.MapPath(".") & "/filefolders/" & RadTree1.SelectedNode.Text & "/")
If nd.Exists = False Then
nd.Create()
End If
RadUpload1.TargetFolder = "~/filefolders/" & RadTree1.SelectedNode.Text & "/"
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
'Dim rootFolder As String = ConfigurationManager.AppSettings("ParentFolderPath")
Dim rootFolder As String = Server.MapPath("~/filefolders/")
Dim rootNode As New RadTreeNode(rootFolder)
rootNode.Text = "Santricity"
rootNode.Value = Server.MapPath("~/filefolders/")
rootNode.ImageUrl = "Folder.gif"
rootNode.Category = "Folder"
rootNode.Expanded = True
RadTree1.Nodes.Add(rootNode)
BindTreeToDirectory(rootFolder, rootNode)
'RadUpload1.TargetFolder = "~/filefolders/" & ("Linux") & "/"
End If
End Sub
End Class
Hello
According to the API available, it is possible to load the content file and the context menus dynamically by setting the following properties
· ContentFile
· ContextMenuContentFile
For e.g.
ContentFile="~/Examples/Programming/ContextMenu/tree.xml"
ContextMenuContentFile="~/Examples/Programming/ContextMenu/ContextMenus.xml"
But we are unable to find the properties in the TreeView control (please see the snapshot below)
Moreover we are able to load the ContentFile dynamically, using the LoadContentFile method as shown below; but the corresponding
LoadContextMenusXmlString is not available (Please see the snapshot below)
We have the following version
Telerik.Web.UI.dll 2009.1.311.35
|
Name: |
Telerik.Web.UI.RadTreeView |
|
Assembly: |
Telerik.Web.UI, Version=2009.1.311.35 |
Please let me know if you need to more information.
Regards,
Abhishek