0

I created a treeview in asp.net web page and passed the file system as the nodes of the treeview.I would like to know, If the treeview is provided to display the file structure will it dispay my local system file structure or server machine file structure.?

Code behind:

    Array drivesList = DriveInfo.GetDrives();
    for (int index = 0; index < drivesList.GetLength(0); index++)
    {
        string text = drivesList.GetValue(index).ToString();
        TreeNode parentNode = new TreeNode(text);
        parentNode.PopulateOnDemand = true;
        TreeView1.Nodes.Add(parentNode);
    }
Samiey Mehdi
  • 9,184
  • 18
  • 49
  • 63
user1471194
  • 23
  • 1
  • 5
  • Array drivesList= DriveInfo.GetDrives(); for (int index = 0; index < drivesList.GetLength(0); index++) { string text = drivesList.GetValue(index).ToString(); TreeNode parentNode = new TreeNode(text); parentNode.PopulateOnDemand = true; TreeView1.Nodes.Add(parentNode); } – user1471194 Sep 28 '13 at 06:28

1 Answers1

0

Your ASP.Net code is executed on the server side. So if you fill your tree view using the following code:

Array drivesList= DriveInfo.GetDrives(); 
for (int index = 0; index < drivesList.GetLength(0); index++) 
{ 
  string text = drivesList.GetValue(index).ToString(); 
  TreeNode parentNode = new TreeNode(text); 
  parentNode.PopulateOnDemand = true; 
  TreeView1.Nodes.Add(parentNode); 
}

you will see the logical drives of your server (the drives visible for the user account IIS/your web server process is running on).

The function DriveInfo.GetDrives() returns the logical drives of the computer the code is running on (in your case the server machine).

Hans
  • 12,902
  • 2
  • 57
  • 60
  • how can i get the directory structure of my local system.Please provide me the code. – user1471194 Sep 28 '13 at 09:42
  • @user1471194: You mean the file system of the client where the browser is running? With standard HTML this is not possible. I think the only way would be to write an ActiveX control. Maybe it is also possible using flash or a Java applet - but I don't know for sure. The HTML standard only allows you to choose a file on the client computer for uploading. Please accept my answer (if it helped you) by clicking on the hollow arrow next to the answer. – Hans Sep 28 '13 at 10:01
  • can you help me how to get through it – user1471194 Sep 28 '13 at 10:29
  • @user1471194: What are you trying to accomplish with your software? Why do you need to show the file system in a browser? – Hans Sep 28 '13 at 14:32
  • My client has a requirement to select a folder and selects the folder path and it is saved in the database and he can access it through a link,If he clicks the link the folder window should open – user1471194 Sep 29 '13 at 03:05
  • @user1471194: Should it be an intranet or an internet web application? – Hans Sep 29 '13 at 06:54
  • It is an intranet application – user1471194 Sep 29 '13 at 10:44
  • @user1471194: In case of an intranet application you should consider using a standard WinForms or WPF application (if your environment is windows based). I really need more information about the requirements of your client to further advice you. I think, the comments section/answer section of stackoverflow is too small to help you. So I think I can't really help. The topic is too complex. – Hans Sep 30 '13 at 16:28