本文介绍了如何创建一个动态树视图以显示我的计算机在asp.net中的所有驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我设法使用树形视图列出了我的计算机驱动程序列表,但是我手动添加了该驱动程序,如下所示:
I have managed to make a list of my computers drivers using the tree view, but I added the driver with manually, like below :
TreeNode diskc = new TreeNode("C:\\", "C:\\");
diskc.PopulateOnDemand = true;
TreeView1.Nodes.Add(diskc);
TreeNode diskd = new TreeNode("D:\\", "D:\\");
diskd.PopulateOnDemand = true;
TreeView1.Nodes.Add(diskd);
TreeNode diske = new TreeNode("E:\\", "E:\\");
diske.PopulateOnDemand = true;
TreeView1.Nodes.Add(diske);
如何通过调整计算机中的任何驱动程序自动添加驱动程序?
到目前为止,这是我的全部代码:
how to add drivers automatically by adjusting any driver in your computer ??
so far this below is all my code :
protected void Page_Load(object sender, EventArgs e)
{ if (!IsPostBack)
{
TreeNode diskc = new TreeNode("C:\\", "C:\\");
diskc.PopulateOnDemand = true;
TreeView1.Nodes.Add(diskc);
TreeNode diskd = new TreeNode("D:\\", "D:\\");
diskd.PopulateOnDemand = true;
TreeView1.Nodes.Add(diskd);
TreeNode diske = new TreeNode("E:\\", "E:\\");
diske.PopulateOnDemand = true;
TreeView1.Nodes.Add(diske);
TreeView1.CollapseAll();
}
TreeView1.TreeNodeExpanded += new TreeNodeEventHandler(TreeView1_TreeNodeExpanded);
TreeView1.SelectedNodeChanged += new EventHandler(TreeView1_SelectedNodeChanged);
} void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
ModalPopupExtenderMessage.Show();
_browseTextBox.Text = TreeView1.SelectedValue;
}
void TreeView1_TreeNodeCollapsed(object sender, TreeNodeEventArgs e)
{
ModalPopupExtenderMessage.Show();
//throw new Exception("The method or operation is not implemented.");
}
void TreeView1_TreeNodeExpanded(object sender, TreeNodeEventArgs e)
{
if (e.Node.Value.EndsWith("\\"))
{
AddNodes(e.Node.Value, e.Node);
}
ModalPopupExtenderMessage.Show();
}
private TreeNode AddNodes(string path, TreeNode parentNode)
{
FileList objList = new FileList(path, "*.*");
TreeNode node = new TreeNode(path, path);
for (int index = 0; index < objList.Directories.Length; index++)
{
string directory = objList.Directories[index];
TreeNode objChildNode = new TreeNode(directory, path + "\\" + directory + "\\");
objChildNode.PopulateOnDemand = true;
objChildNode.Target = "_blank";
parentNode.ChildNodes.Add(objChildNode);
}
foreach (string file in objList.Files)
{
TreeNode objChildNode = new TreeNode(file, path + "\\" + file);
parentNode.ChildNodes.Add(objChildNode);
}
ModalPopupExtenderMessage.Show();
return node;
}
protected void _browseButton_Click(object sender, ImageClickEventArgs e)
{
string path = _browseTextBox.Text.ToUpper();
if (path != "")
{
TreeNode > 0)
{
return System.IO.File.Exists(_browseTextBox.Text);
}
}
ModalPopupExtenderMessage.Show();
return true;
}
推荐答案
报价:
如何通过调整自动添加驱动程序计算机中的任何驱动程序??
how to add drivers automatically by adjusting any driver in your computer ??
无法从Web应用程序访问您要访问的云端硬盘信息.
由于安全限制,浏览器不允许这样做.
From a web app you want to access the Drive information, which is not possible.
Browsers won''t allow this due to security restrictions.
这篇关于如何创建一个动态树视图以显示我的计算机在asp.net中的所有驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!