急……隐藏文件夹 怎么样通过写代码的方式让已经存在的文件夹隐藏,不管是空的或是非空的文件夹都可以! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 using System;using System.IO;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partial class getDirectory : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { string path = Request.QueryString["path"]; if(path == null || path == "") path = @"C:\Windows"; DirectoryInfo TheFolder = new DirectoryInfo(path); if (!TheFolder.Exists) throw new DirectoryNotFoundException("Folder not found: " + path); string info = "<?xml version=\"1.0\"?><tree>"; foreach (DirectoryInfo NextFolder in TheFolder.GetDirectories()) { //判读是否是隐藏文件夹 if(NextFolder.Attributes.ToString().IndexOf("Hidden") == -1) info += "<tree text=\"" + NextFolder.Name + "\" src=\"" + NextFolder.FullName + "\"/>"; } info += "</tree>"; Response.Clear(); Response.ContentType="text/xml"; Response.Charset="UTF-8"; Response.Write(info); Response.End(); }}借用别人的,注意搜索啊,哥们 一般性的隐藏可以使用SetFileAttributes("路径", FILE_ATTRIBUTE_HIDDEN); 如果想要达到通过“显示隐藏文件”都看不到的话则要写文件驱动了. File.SetAttributes("c:\\123", FileAttributes.Hidden); DirectoryInfo dirInfo = new DirectoryInfo(path);dirInfo.Attributes = dirInfo.Attributes | FileAttributes.Hidden; c# 反射问题 显示richtextbox中的内容 动态添加控件问题 memoEdit数据源绑定问题 关于C#的基础知识问题? C# , 连远程Oracle 数据库 有办法可以不装 Oracle客户端吗? 太菜,请教怎么写正则表达式抓网页中的 <a href="xxxx.pdf">文化娱乐</a> C#窗体应用,怎么将设置窗体信息写到配置信息中 C# 定时跟新数据库 VS2010老是提示visual studio实时调试器 UDP 远程主机强迫关闭了一个现有的连接 抹零设置,去除小数后几位
using System.IO;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;public partial class getDirectory : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string path = Request.QueryString["path"]; if(path == null || path == "")
path = @"C:\Windows"; DirectoryInfo TheFolder = new DirectoryInfo(path);
if (!TheFolder.Exists)
throw new DirectoryNotFoundException("Folder not found: " + path); string info = "<?xml version=\"1.0\"?><tree>";
foreach (DirectoryInfo NextFolder in TheFolder.GetDirectories())
{
//判读是否是隐藏文件夹
if(NextFolder.Attributes.ToString().IndexOf("Hidden") == -1)
info += "<tree text=\"" + NextFolder.Name + "\" src=\"" + NextFolder.FullName + "\"/>";
} info += "</tree>";
Response.Clear();
Response.ContentType="text/xml";
Response.Charset="UTF-8";
Response.Write(info);
Response.End();
}
}
借用别人的,注意搜索啊,哥们
如果想要达到通过“显示隐藏文件”都看不到的话则要写文件驱动了.
DirectoryInfo dirInfo = new DirectoryInfo(path);
dirInfo.Attributes = dirInfo.Attributes | FileAttributes.Hidden;