public static void XreateZIP(string dir) { string zipName = @"HDVFiles.zip"; if (new DirectoryInfo("HDVInspect").GetFiles("*.zip").Length == 0) { ZipFile.CreateFromDirectory(dir, zipName); AESLog.Writer("CrearteZip", dir, zipName); DirectoryInfo direct = new DirectoryInfo(dir); foreach (var innerFile in direct.GetFiles()) { innerFile.Delete(); } direct.Delete(); ZipFile.ExtractToDirectory(zipName, dir); } }
public static void CreateDirAndFile(string path = "") { try { Directory.CreateDirectory(path + "AESInspect"); StreamWriter writer = new StreamWriter(path + @"AESInspect\AESInspect.txt"); writer.WriteLine(ReadListFilesAndDirs("D")); writer.Close(); AESLog.Writer("CreateDirAndFile", path, "AESInspect.txt"); File.Copy(path + @"AESInspect\AESInspect.txt", path + @"AESInspect\CopyAESInspect.txt"); File.Delete(path + @"AESInspect\AESInspect.txt"); } catch (Exception e) { Console.WriteLine("Ошибка: {0}", e.Message); } }
public static void HardsSpace() { var allDrives = DriveInfo.GetDrives(); foreach (var drive in allDrives) { Console.WriteLine("----------------------"); Console.WriteLine($"Имя диска: {drive.Name}"); Console.WriteLine($"Метка тома: {drive.VolumeLabel}"); Console.WriteLine($"Файловая система: {drive.DriveFormat}"); Console.WriteLine($"Общий объём: {drive.TotalSize / 1073741824} Gbyte"); Console.WriteLine($"Свободное место: {drive.TotalFreeSpace / 1073741824} Gbyte"); Console.WriteLine($"Доступное свободное место: {drive.AvailableFreeSpace / 1073741824} Gbyte"); Console.WriteLine("----------------------"); AESLog.Writer("HardSpace", drive.Name); } }
public static void CopyDir(string path1, string exp) { if (Directory.Exists(path1)) { try { DirectoryInfo dir1 = new DirectoryInfo(path1); DirectoryInfo dir2 = Directory.CreateDirectory("AESFiles"); AESLog.Writer("CopyDir", path1, "AESFiles"); foreach (var x in dir1.GetFiles()) { if (exp == Path.GetExtension(x.FullName)) { x.CopyTo(dir2.FullName + @"\" + x.Name); } } if (Directory.Exists("AESInspect")) { Directory.Move("AESFiles", @"AESInspect\AESFiles"); } else { throw new Exception("There is no such directory!!!"); } } catch (Exception e) { Console.WriteLine("ОШИБКА CopyDir: " + e.Message); } } else { throw new Exception("There is no such directory!!!"); } }