Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
140
Using WebDataTree to show the File system on the server...
posted

HI all,

I am exploring the infragistics web controls and i want to know how do we use the webtree control to display the file system on the server. I don't want to display the entire file system structure, but a structure within a specific drive or folder.

e.g. the root folder for my application "MyApp" and contains other folders..

MyApp 

    l___Folder1

                  l___file1

                  l___file2

   l___Folder2

   l___Folder3

How can I display this by using the webtree control.

I would really appriciate your help on this.

Thank you in advance.

Parents
  • 3726
    Suggested Answer
    posted

    Well in Page_Load you can enumerate your file system using the .NET System.IO.Directory class and call EnumerateDirectory() and EnumerateFiles(). After you have that info you have to start adding new Nodes to the tree by:

    DataTreeNode dtn = new DataTreeNode();

    dtn.Text = file name/directory name;

    WebDataTree1.Nodes.Add(dtn) ;

    Of course you have to traverse the Nodes collections so that you properly create the file system hierarchy.

    In order to display folders and files image in front of each node you have to specify the following NodeSettings in the markup:

    <NodeSettings ParentNodeImageUrl="DirectoryImage.png" LeafNodeImageUrl="FileImage.png" />

    Hope this helps.

Reply Children
No Data