예제 #1
0
 static void Main(string[] args)
 {
     SDS_DiskInfo.Show_Disks();
     SDS_FileInfo.GetFileInformation("D:\\File.txt");
     SDS_DirInfo.GetDirectoryInformation("D:\\Steam");
     SDS_FileManager.Manager("D:\\");
     SDS_Log.CloseStream();
 }
예제 #2
0
 public static void Show_Disks()
 {
     SDS_Log.WriteMessage("Получение общих сведений о дисках");
     DriveInfo[] drives = DriveInfo.GetDrives();
     foreach (var drive in drives)
     {
         Console.WriteLine("Disk " + drive.Name);
         Console.WriteLine("Disk Type: " + drive.DriveType);
         if (drive.IsReady)
         {
             Console.WriteLine("Space: " + drive.TotalSize);
             Console.WriteLine("Free Space: " + drive.TotalFreeSpace);
             Console.WriteLine("Disk Marker: " + drive.VolumeLabel);
             Console.WriteLine("Disk Format: " + drive.DriveFormat);
         }
         Console.WriteLine();
     }
 }
예제 #3
0
        public static void GetFileInformation(string Name)
        {
            FileInfo file = new FileInfo(Name);

            if (file.Exists)
            {
                SDS_Log.WriteMessage("Подучение информации о файле", file.Name, file.FullName);
                Console.WriteLine("File: " + file.Name);
                Console.WriteLine("Size: " + file.Length);
                Console.WriteLine("Extension: " + file.Extension);
                Console.WriteLine("Full Way: " + file.FullName);
                Console.WriteLine("Time of Create: " + file.CreationTime + "\n");
            }
            else
            {
                SDS_Log.WriteMessage("Поиск файла - Файл отсутствует");
                Console.WriteLine("File is not found!" + "\n");
            }
        }
예제 #4
0
        public static void GetDirectoryInformation(string Name)
        {
            DirectoryInfo file = new DirectoryInfo(Name);

            if (file.Exists)
            {
                SDS_Log.WriteMessage("Подучение информации о папке", file.Name, file.FullName);
                Console.WriteLine("Directory: " + file.Name);
                Console.WriteLine("Count of Files: " + file.GetFiles().Count());
                Console.WriteLine("Count of SubDirectory: " + file.GetDirectories().Count());
                Console.WriteLine("Name of Parent: " + file.Parent);
                Console.WriteLine("Full Way: " + file.FullName);
                Console.WriteLine("Time of Create: " + file.CreationTime + "\n");
            }
            else
            {
                SDS_Log.WriteMessage("Поиск папки - папка отсутствует");
                Console.WriteLine("Directory is not found!" + "\n");
            }
        }
예제 #5
0
        public static void Manager(string Disk)
        {
            DirectoryInfo dir = new DirectoryInfo(Disk);

            if (dir.Exists)
            {
                string sub_name = Disk + "SDS_Inspect\\";

                Make_Directory(sub_name);
                SDS_Log.WriteMessage("Создание папки", "SDS_Inspect", sub_name);

                string File_Name = sub_name + "SDS_dirinfo.txt";

                Make_File_Write(File_Name, dir);
                SDS_Log.WriteMessage("Создание файла", "SDS_dirinfo.txt", File_Name);

                string New_Name = File_Name.Insert(File_Name.Length - 4, "_2");

                File.Copy(File_Name, New_Name, true);
                SDS_Log.WriteMessage("Создание копии файла", "SDS_dirinfo.txt", File_Name);
                SDS_Log.WriteMessage("Новый скопированный файл", "SDS_dirinfo_2.txt", File_Name);

                File.Delete(File_Name);
                SDS_Log.WriteMessage("Удаление файла", "SDS_dirinfo.txt", File_Name);

                string sub_name_2 = Disk + "SDS_Files\\";

                Make_Directory(sub_name_2);
                SDS_Log.WriteMessage("Создание папки", "SDS_Files", sub_name_2);

                Move_Type(Disk, sub_name_2, ".txt");
                SDS_Log.WriteMessage("Перемещение файлов определенного типа", Disk, Disk);

                if (!Directory.Exists(sub_name + "SDS_Files\\"))
                {
                    Directory.Move(sub_name_2, sub_name + "SDS_Files\\");
                    SDS_Log.WriteMessage("Перемещение папки SDS_Files в SDS_Inspect");
                }

                if (!File.Exists(sub_name + "Archive.zip"))
                {
                    ZipFile.CreateFromDirectory(sub_name + "SDS_Files\\", sub_name + "Archive.zip");
                }
                var  a    = ZipFile.OpenRead(sub_name + "Archive.zip");
                bool Flag = true;
                foreach (var item in a.Entries)
                {
                    if (File.Exists("D:\\SDS_ZIP\\" + item.Name))
                    {
                        Flag = false;
                        break;
                    }
                }
                if (Flag)
                {
                    ZipFile.ExtractToDirectory(sub_name + "Archive.zip", "D:\\SDS_ZIP");
                }
                SDS_Log.WriteMessage("Работа с архивом");
            }
            else
            {
                Console.WriteLine("Disk " + Disk + " is not ready or find!");
            }
        }