When treeview data in c# is provided with filesystem, will it display server system files or local system files?

StackOverflow https://stackoverflow.com/questions/19063952

سؤال

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);
    }
هل كانت مفيدة؟

المحلول

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).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top