CAPMAT
Сообщений: 86
Оценки: 0
Присоединился: 2007-08-16 11:00:21.310000
|
Предыстория: Знакомый принес на флешке вирус,который скрывает папки и заменяет собой эту папку.Nod вирус удалил,но в свойствах папки параметр "скрытый" поменять нельзя-заблокирован(аналок свойства enabled в checkbox'e).решил написать программу,,меняющую параметры папки.Но что то этого не происходит. Код C#
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
bool OpenDir;
DirectoryInfo di;
FileAttributes fi;
private void button1_Click(object sender, EventArgs e)
{
OpenDir = true;
FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
label_DirPath.Text = folderBrowserDialog1.SelectedPath;
di = new DirectoryInfo(folderBrowserDialog1.SelectedPath);
fi = di.Attributes;
if ((fi & FileAttributes.Hidden)==FileAttributes.Hidden)
{
checkBox_Hidden.Checked = true;
}
else if ((fi & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
{
checkBox_ReadOnly.Checked = true;
}
else if ((fi & FileAttributes.System)==FileAttributes.System)
{
checkBox_System.Checked = true;
}
label1.Text = "Сохраните свойства папки";
}
else
{
return;
}
}
private void Form1_Load(object sender, EventArgs e)
{
OpenDir = false;
}
private void button2_Click(object sender, EventArgs e)
{
if (OpenDir == false)
{
label1.Text = "Сначала выберите каталог!";
}
else
{
if (checkBox_Hidden.Checked == true)
{
di.Attributes = FileAttributes.Hidden;
}
if (checkBox_ReadOnly.Checked == true)
{
di.Attributes = FileAttributes.ReadOnly;
}
if (checkBox_System.Checked == true)
{
di.Attributes = FileAttributes.System;
}
}
}
}
В чем я ошибся?
|