示例#1
0
        public static void Zip()
        {
            ZipFile.CreateFromDirectory(@"D:\учеба\ООП\lab13\BVAInspect\BVAFilesNEW", @"D:\учеба\ООП\lab13\BVAInspect\Archive.rar");
            Console.WriteLine("Zip Archive.rar is created");

            BVALog.OpenFile().WriteLine($"{DateTime.Now}\nCreating Zip Archive.rar\nPath: D:\\учеба\\ООП\\lab13\\BVAInspect\\BVAFiles\n@");
        }
示例#2
0
        public static void Unzip()
        {
            ZipFile.ExtractToDirectory(@"D:\учеба\ООП\lab13\BVAInspect\Archive.rar", @"D:\учеба\ООП\lab13");
            Console.WriteLine("Unzipping is successful");

            BVALog.OpenFile().WriteLine($"{DateTime.Now}\nUnzipping Archive.rar\nPath:  D:\\учеба\\ООП\\lab13\\BVAInspect\n@");
        }
示例#3
0
        public static void CopyAndRenameFile()
        {
            File.Copy(@"D:\учеба\ООП\lab13\BVAInspect\BVAdirinfo.txt", @"D:\учеба\ООП\lab13\BVAInspect\BVAdirinfoNew.txt");
            Console.WriteLine("File BVAdirinfo.txt is copied and renamed");

            BVALog.OpenFile().WriteLine($"{DateTime.Now}\nCopying and renaming BVAdirinfo.txt\nPath: D:\\учеба\\ООП\\lab13\\BVAInspect\\BVAdirinfo.txt@");
        }
示例#4
0
        public static void MoveNewDir()
        {
            Directory.Move(@"D:\учеба\ООП\lab13\BVAFiles", @"D:\учеба\ООП\lab13\BVAInspect\BVAFilesNEW");
            Console.WriteLine("New directory BVAFiles is moved");

            BVALog.OpenFile().WriteLine($"{DateTime.Now}\nMoving directory BVAFiles\nPath: D:\\учеба\\ООП\\lab13\\BVAInspect\\BVAFiles");
        }
示例#5
0
        public static void WriteInFile()
        {
            string[]      NumOfFiles = new string[50];
            string[]      NumOfDir   = new string[50];
            DirectoryInfo dir        = new DirectoryInfo(@"C:\");

            Directory.CreateDirectory(@"D:\учеба\ООП\lab13\BVAInspect");
            StreamWriter dirfile = new StreamWriter(@"D:\учеба\ООП\lab13\BVAInspect\BVAdirinfo.txt", true);

            dirfile.WriteLine("-----------Files-----------:");
            foreach (var x in dir.GetFiles())
            {
                dirfile.WriteLine($"{x}");
            }
            dirfile.WriteLine("\n-----------Directories-----------");
            foreach (var y in dir.GetDirectories())
            {
                dirfile.WriteLine($"{y}");
            }
            dirfile.Close();
            Console.WriteLine("File BVAdirinfo.txt is created");
            BVALog.OpenFile();

            BVALog.OpenFile().WriteLine($"{DateTime.Now}\nCreating BVAdirinfo.txt\nPath: {dir.FullName}\n@");
        }
示例#6
0
        public static void DeleteOldFile()
        {
            File.Delete(@"D:\учеба\ООП\lab13\BVAInspect\BVAdirinfo.txt");
            Console.WriteLine("File BVAdirinfo.txt is deleted");
            Console.WriteLine();

            BVALog.OpenFile().WriteLine($"{DateTime.Now}\nDeleting old BVAdirinfo.txt\nPath: D:\\учеба\\ООП\\lab13\\BVAInspect\\BVAdirinfo.txt@");
        }
示例#7
0
        public static void TimeInfo(string str)
        {
            Console.WriteLine("File created: " + File.GetCreationTime(str));
            Console.WriteLine("File changed: " + File.GetLastAccessTime(str));
            Console.WriteLine();

            BVALog.OpenFile().WriteLine($"{DateTime.Now}\nChecking file creation time\nFile name: {Path.GetFileNameWithoutExtension(str)}\nPath: {str}\n@");
        }
示例#8
0
        public static void FilePath(string path)
        {
            var FullPath = Path.GetFullPath(path);

            Console.WriteLine($"{FullPath}");
            Console.WriteLine();

            BVALog.OpenFile().WriteLine($"{DateTime.Now}\nChecking path to file\nFile name: {path}\nPath: {FullPath}\n@");
        }
示例#9
0
        public static void SubDir(DirectoryInfo dir)
        {
            int num = 0;

            foreach (var x in dir.GetDirectories())
            {
                num++;
            }
            Console.WriteLine($"Number of subdirectories: {num}");
            BVALog.OpenFile().WriteLine($"{DateTime.Now}\nChecking number of subdirectories\nPath: {dir.FullName}\n@");
            Console.WriteLine();
        }
示例#10
0
        public static void SizeExtensionName(string path)
        {
            var fileSize      = path.Length;
            var fileExtension = Path.GetExtension(path);
            var fileName      = Path.GetFileNameWithoutExtension(path);

            Console.WriteLine($"File name: {fileName}");
            Console.WriteLine($"File size: {fileSize}");
            Console.WriteLine($"File extension: {fileExtension}");
            Console.WriteLine();

            BVALog.OpenFile().WriteLine($"{DateTime.Now}\nChecking file size, extension and name\nFile name: {fileName}\nPath: {path}\n@");
        }
示例#11
0
        public static void FileSystemInfo()
        {
            DriveInfo[] driveinfo = DriveInfo.GetDrives();

            foreach (DriveInfo item in driveinfo)
            {
                Console.WriteLine("Drive {0}", item.Name);
                if (item.IsReady == true)
                {
                    Console.WriteLine("  File system: {0}", item.DriveFormat);
                }
            }

            BVALog.OpenFile().WriteLine($"{DateTime.Now}\nScan file system\n@");
            Console.WriteLine();
        }
示例#12
0
        public static void NewDir()
        {
            Directory.CreateDirectory(@"D:\учеба\ООП\lab13\BVAFiles");
            DirectoryInfo dir = new DirectoryInfo(@"D:\учеба\ООП\lab13\OOP_Lab13");

            foreach (var x in dir.GetFiles())
            {
                if (Equals(x.Extension, ".sln"))
                {
                    File.Copy(@"D:\учеба\ООП\lab13\OOP_Lab13\" + x.Name, @"D:\учеба\ООП\lab13\BVAFiles\" + x.Name);
                }
            }
            Console.WriteLine("New directory BVAFiles is created");

            BVALog.OpenFile().WriteLine($"{DateTime.Now}\nCreating directory BVAFiles\nPath: {dir.FullName}\n@");
        }
示例#13
0
        public static void DefaultInfo()
        {
            DriveInfo[] driveinfo = DriveInfo.GetDrives();

            foreach (DriveInfo item in driveinfo)
            {
                Console.WriteLine("Drive {0}", item.Name);
                if (item.IsReady == true)
                {
                    Console.WriteLine("  Total size of drive:            {0, 15} bytes ", item.TotalSize);
                    Console.WriteLine("  Available space to current user:{0, 15} bytes", item.AvailableFreeSpace);
                }
            }

            BVALog.OpenFile().WriteLine($"{DateTime.Now}\nScan total, available space and volume label of drive\n@");
            Console.WriteLine();
        }
示例#14
0
        static void Main(string[] args)
        {
            try
            {
                //очистка возможно созданных прежде файлов и директориев
                Directory.Delete(@"D:\учеба\ООП\lab13\BVAInspect", true);
                File.Delete(@"D:\учеба\ООП\lab13\OOP_Lab13.sln");
                File.Delete(@"D:\учеба\ООП\lab13\BVAlogfile.txt");
            }
            catch
            { }

            BVADiskInfo.PrintDiskInfo();
            BVAFileInfo.PrintFileInfo(@"D:\учеба\ООП\lab13\OOP_Lab13\ReadMe.txt");
            BVADirInfo.PrintDirInfo(new DirectoryInfo(@"D:\учеба\ООП"));
            BVAFileManager.PrintFileManager();
            BVALog.CloseFile();

            //для 6(шестого) задания
            BVALog.BVAWrite();
            BVALog.BVADeletePartOfFile(20);
        }
示例#15
0
 public static void ParentDir(DirectoryInfo dir)
 {
     Console.WriteLine($"Parent directory: {dir.Parent}");
     BVALog.OpenFile().WriteLine($"{DateTime.Now}\nChecking parent directory\nPath: {dir.FullName}\n@");
     Console.WriteLine();
 }
示例#16
0
 public static void Time(DirectoryInfo dir)
 {
     Console.WriteLine($"Creation time: {dir.CreationTime}");
     BVALog.OpenFile().WriteLine($"{DateTime.Now}\nChecking directory creation time\nPath: {dir.FullName}\n@");
     Console.WriteLine();
 }