static public void DirInfo() { Console.WriteLine("Information about directory"); Console.WriteLine("Number of files in the directory: " + dirInf.GetFiles().Length); Console.WriteLine("Time of creation: " + dirInf.CreationTime); Console.WriteLine("Number of subdirectories: " + dirInf.GetDirectories().Length); Console.WriteLine("Parent directory list: " + dirInf.Parent); Console.WriteLine(); GEVLog.WriteLog("use DirInfo"); }
static public void SecondManager(string path) { DirectoryInfo dir1 = new DirectoryInfo(path + "GEVFiles"); dir1.Create(); DirectoryInfo dir2 = new DirectoryInfo("G:\\textFiles"); foreach (FileInfo file in dir2.GetFiles()) { if (file.Extension == ".txt") { file.CopyTo(path + "GEVFiles\\" + file.Name); } } dir1.MoveTo("G:\\GEVInspect\\GEVFiles"); Console.WriteLine("Operation completed"); GEVLog.WriteLog("use SecondManager"); }
static public void FirstManager(string path) { DirectoryInfo dir1 = new DirectoryInfo(path + "GEVInspect"); DirectoryInfo dir2 = new DirectoryInfo(path); dir1.Create(); StreamWriter sw = new StreamWriter(path + "/GEVInspect/GEVDirInfo.txt"); sw.WriteLine("Number of directories: " + dir2.GetDirectories().Length); sw.WriteLine("Number of files: " + dir2.GetFiles().Length); sw.Close(); FileInfo file = new FileInfo(path + "/GEVInspect/GEVDirInfo.txt"); file.CopyTo(path + "/GEVInspect/GEVSecondDirInfo.txt", true); file.Delete(); Console.WriteLine("Operation completed"); GEVLog.WriteLog("use FirstManager"); }
static public void FileInfo() { string path = "G:\\BOOTEX.LOG"; FileInfo fileInf = new FileInfo(path); Console.WriteLine("Information about file"); if (fileInf.Exists) { Console.WriteLine("Full path: " + Path.GetFullPath(path)); Console.WriteLine("File name: " + fileInf.Name); Console.WriteLine("File size: " + fileInf.Length); Console.WriteLine("File extension: " + fileInf.Extension); Console.WriteLine("Time of creation: " + fileInf.CreationTime); Console.WriteLine(); } GEVLog.WriteLog("use FileInfo"); }
static public void DriverInfo() { Console.WriteLine("Information about disk"); foreach (DriveInfo drive in DriveInfo.GetDrives()) { if (drive.Name == "D:\\") { Console.WriteLine("Disk name: " + drive.Name); Console.WriteLine("File system: " + drive.DriveFormat); Console.WriteLine("Volume Label: " + drive.VolumeLabel); Console.WriteLine("Free disk space: " + drive.TotalFreeSpace); Console.WriteLine("Total size: " + drive.TotalSize); Console.WriteLine("Available: " + drive.AvailableFreeSpace); Console.WriteLine(); } } GEVLog.WriteLog("use DriverInfo"); }
static void Main(string[] args) { GEVLog.ReadLog(); Console.WriteLine(GEVLog.FindLog("DirInfo")); GEVLog.LongLog(); GEVLog.LogForTheLastHours(); GEVLog.ReadLog(); GEVLog.LongLog(); GEVFileInfo.FileInfo(); GEVDirInfo.DirInfo(); GEVDiskInfo.DriverInfo(); GEVFileManager.FirstManager("G:\\"); GEVFileManager.SecondManager("G:\\"); Console.ReadKey(); }