×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to show hard disk tree view in asp.net application of client machi

How to show hard disk tree view in asp.net application of client machi

How to show hard disk tree view in asp.net application of client machi

(OP)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Configuration;
using System.Data;
using System.IO;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Media;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;

namespace treeview_asp
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {


           /* getDrives();
            if (cDrives.Items.Count != 0)
                cDrives.Text = cDrives.Items[0].ToString();*/


            if (Page.IsPostBack == false)
            {
               // System.IO.DirectoryInfo RootDir = new System.IO.DirectoryInfo(Server.MapPath("~/"));
             // System.IO.DirectoryInfo RootDir = new System.IO.DirectoryInfo("C:\\Users\\SAYAK");
                System.IO.DirectoryInfo RootDir = new System.IO.DirectoryInfo("K:\\SilverlightApplication1");
                //System.IO.DriveInfo abcd = new System.IO.DriveInfo("k");
               // string[] name = Directory.GetDirectories("C:\\Users\\SAYAK\\Desktop");
               // System.IO.DirectoryInfo RootDir = new System.IO.DirectoryInfo(name[0]);
               
                
                // output the directory into a node
                TreeNode RootNode = OutputDirectory(RootDir, null);
              //  TreeNode RootNode = OutputDrive(abcd, null);

                // add the output to the tree

                MyTree.Nodes.Add(RootNode);

            }
        }

          TreeNode OutputDirectory(System.IO.DirectoryInfo directory, TreeNode parentNode)
    {
        // validate param
        if (directory == null) return null;

        // create a node for this directory

        TreeNode DirNode = new TreeNode(directory.Name);

        // get subdirectories of the current directory

        System.IO.DirectoryInfo[] SubDirectories = directory.GetDirectories();

       // OutputDirectory(SubDirectories[0], "Directories");

        // output each subdirectory

        for (int DirectoryCount = 0; DirectoryCount < SubDirectories.Length; DirectoryCount++)

        {

            OutputDirectory(SubDirectories[DirectoryCount], DirNode);

        }

        // output the current directories file

        System.IO.FileInfo[] Files = directory.GetFiles();

        for (int FileCount = 0; FileCount < Files.Length; FileCount++)

        {

            DirNode.ChildNodes.Add(new TreeNode(Files[FileCount].Name));

        }        // if the parent node is null, return this node

        // otherwise add this node to the parent and return the parent

        if (parentNode == null)

        {

            return DirNode;

        }

        else

        {

            parentNode.ChildNodes.Add(DirNode);

            return parentNode;
        }

        /*private void getDrives()
        {
            foreach (DriveInfo drive in DriveInfo.GetDrives())
            {
                if (drive.IsReady) //Check to see there is something in the drive
                   // cDrives.Items.Add(drive.RootDirectory);
                    DropDownList1.Items.Add("C:\\");
            }
        }*/


    }

  }

Is there other process to show the total hard disk tree view in web application?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close