【发布时间】:2009-06-12 05:04:31
【问题描述】:
我想在 Windows Vista 中隐藏一个目录。只是从视图中没有完全隐藏。就像您从文件夹选项中设置的一样。 我尝试了一些我看到的例子。只是我稍微修改了一下..
这是我所有的代码组合。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class hideme : Form
{
public hideme()
{
InitializeComponent();
}
private void button3_Click(object sender, EventArgs e)
{
if (PasswordTextBox.Text == "test")
{
EnableButton.Visible = true;
DisableButton.Visible = true;
}
else
{
MessageBox.Show("Wrong", "Attention");
Application.Exit();
}
}
private void EnableButton_Click(object sender, EventArgs e)
{
//System.IO.FileInfo dir = new System.IO.FileInfo("C:\\Users\\logickills\\Pictures\\system");
string path = "C:\\Users\\chris\\Pictures\\system";
FileInfo FIh1 = new FileInfo(Environment.CurrentDirectory + @"\Files\File2.txt");
FIh1.Attributes = FileAttributes.Hidden;
}
private void DisableButton_Click(object sender, EventArgs e)
{
}
private void PasswordTextBox_TextChanged(object sender, EventArgs e)
{
}
}
}
这与我之前创建的对话框 here 一起使用。 输入密码后显示的两个按钮用于显示和隐藏该目录。
【问题讨论】:
-
您能否更清楚地说明您的问题?你的例子行不通吗?
-
不知道隐藏文件夹有多实用!您的意思是“以编程方式”吗?
-
@matt:我也想知道:p
-
@matt:你太搞笑了!我现在是 ROFL。