ASP.NET 模拟Windows资源管理器
来源:互联网 发布:大掌门杨过成长数据 编辑:程序博客网 时间:2024/06/08 02:12
Windows中文件资源管理主要是通过“Windows资源管理器”来完成,如果想在网络上实现文件的远程浏览,可以通过如下几种方法:
1、FTP
2、Remote Desktop Manager
3、WWW
其中前两种方法只能是一对一的管理,不能针对多人资源共享的情况(比如我想将服务器上的各种资源提供给外部浏览、下载),而通过WWW进行文件资源的访问则是可行的方法,使用者只要有浏览器就能访问网络资源,没有其他的限制。
Windows资源管理器主要由三个部分组成,如图:
三个部分的作用是:
地址栏:显示文件或目录的地址,可以点击任何一级进入相应的位置;
文件树:显示从根目录到所有子目录(不包括文件)的树状结构;
目录或文件:显示打开位置的文件或目录;
使用ASP.NET模拟的效果如下:
在Web.Config中指定根目录:
<appSettings>
<add key="tooltipnum" value="60"/>
<add key="NetDisk" value="E:\根文件夹"/>
</appSettings>
实现目录的遍历函数如下:
//递归目录
public static void ListFolds(DirectoryInfo theDir, TreeView tvwAll, TreeNode tr0, bool goNext)
{
DirectoryInfo[] subDirectories = theDir.GetDirectories();//获得目录
string strValue = string.Empty;
foreach (DirectoryInfo dirinfo in subDirectories)
{
TreeNode tr = new TreeNode();
tr.Text = CommonMethods.FixLenString(dirinfo.Name.ToString(), 1, 22);
tr.ToolTip = CommonMethods.FixLenString(dirinfo.Name.ToString(), 0, 22);//超过22个字符则显示"..."
tr.NavigateUrl = null;
tr.ImageUrl = CommonMethods.SetIcon("folder");
strValue = (tr.ToolTip.Length > 0) ? tr.ToolTip : tr.Text;
tr.Value = tr0.Value + "\\" + strValue;
tr0.ChildNodes.Add(tr);
if (goNext)
{
//递归下一个目录
ListFolds(dirinfo, tvwAll, tr, goNext);
}
else
{
ListFolds_Temp(dirinfo, tvwAll, tr);
}
}
}
为提高首页的显示利率,目录树最好不要一次性加载完,打开首页时只显示第一层目录,如果某个目录还有子目录,则在其下方添加一个“等待加载子节点 ...”子节点。当用户点击左方的加号时再动态加载下层的目录。
实现如下:
// 若下一层有目录,则在下一层添加“等待加载子节点 ...”节点
public static void ListFolds_Temp(DirectoryInfo theDir, TreeView tvwAll, TreeNode tr0)
{
DirectoryInfo[] subDirectories = theDir.GetDirectories();//获得目录
if (subDirectories.Length > 0)
{
TreeNode tr = new TreeNode();
tr.Text = "等待加载子节点 ...";
tr.NavigateUrl = null;
tr.ImageUrl = CommonMethods.SetIcon("folder");
tr0.ChildNodes.Add(tr);
}
}
// 点击加载所有的子目录
protected void tvwRes_TreeNodeExpanded(object sender, TreeNodeEventArgs e)
{
bool first = false;
if (e != null)
{
tnSelected = e.Node;
tnSelected.ImageUrl = CommonMethods.SetIcon("folderopen");
foreach (TreeNode node in tnSelected.ChildNodes)
{
if (node.Text == "等待加载子节点 ...")
{
first = true;
}
}
if (first)
{
string strPath = e.Node.ValuePath;
strPath = strPath.Replace("\\", "\\\\");
strPath = strPath.TrimStart('/');
tnSelected.ChildNodes.Clear();
DirectoryInfo thisOne = new DirectoryInfo(TopDir + strPath);
clsFile.ListFolds(thisOne, tvwRes, tnSelected, true);
}
}
}
- ASP.NET 模拟Windows资源管理器
- ASP.NET程序模仿windows资源管理器(xml, xsl, javascript, asp.net (treeView) 的结合使用
- WPF示例: 简单模拟Windows资源管理器
- asp.net身份模拟
- ASP.NET 模拟身份
- ASP.NET 模拟
- 已有文件夹添加到ASP.NET解决方案资源管理器中
- ASP.NET实现身份模拟
- ASP.NET实现身份模拟
- ASP.NET实现身份模拟
- ASP.NET POST模拟登陆
- 在asp.net模拟用户
- ASP.NET Windows身份验证
- 将集成Windows认证并使用了身份模拟的ASP.net应用改成Form认证
- Windows 2008 server + IIS 7 设置身份模拟(ASP.NET impersonation)
- windows资源管理器树形查看
- Windows 资源管理器命令行参数
- Delphi编写Windows资源管理器
- ffmpeg参数中文详细解释
- path的data属性外形描述表示法字母的含义
- 3周项目1(1)
- 数据库一二三BC范式详解
- “上手段”解决不了拆迁问题
- ASP.NET 模拟Windows资源管理器
- daliu_IT学习Android笔记第九篇--Android工程的目录结构详解
- Android中pendingIntent的理解
- 如何定位导致Crash的代码位置
- 算法分类总结
- C++ 对象的内存布局(下)
- Java加密算法 DSA 和 数字签名
- Git 快速上手
- NPOI 2.0 教程(一):创建新EXCEL文件