Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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!

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

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Thanks for a great forum. My problem was answered just by scrolling through previously solved problems. Great service!!..."

Geography

Where in the world do Tek-Tips members come from?

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

sykbhowal (Programmer)
20 Apr 12 6:51
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?

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!

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