Ejemplo n.º 1
0
        public static void Unzip()
        {
            ZipFile.ExtractToDirectory(@"D:\учеба\ООП\lab13\SDLInspect\Archive.rar", @"D:\учеба\ООП\lab13");
            Console.WriteLine("Unzipping is successful");

            SDLLog.OpenFile().WriteLine($"{DateTime.Now}\nUnzipping Archive.rar\nPath:  D:\\учеба\\ООП\\lab13\\SDLInspect\n@");
        }
Ejemplo n.º 2
0
        public static void MoveNewDir()
        {
            Directory.Move(@"D:\учеба\ООП\lab13\SDLFiles", @"D:\учеба\ООП\lab13\SDLInspect\SDLFilesNEW");
            Console.WriteLine("New directory SDLFiles is moved");

            SDLLog.OpenFile().WriteLine($"{DateTime.Now}\nMoving directory SDLFiles\nPath: D:\\учеба\\ООП\\lab13\\SDLInspect\\SDLFiles");
        }
Ejemplo n.º 3
0
        public static void Zip()
        {
            ZipFile.CreateFromDirectory(@"D:\учеба\ООП\lab13\SDLInspect\SDLFilesNEW", @"D:\учеба\ООП\lab13\SDLInspect\Archive.rar");
            Console.WriteLine("Zip Archive.rar is created");

            SDLLog.OpenFile().WriteLine($"{DateTime.Now}\nCreating Zip Archive.rar\nPath: D:\\учеба\\ООП\\lab13\\SDLInspect\\SDLFiles\n@");
        }
Ejemplo n.º 4
0
        public static void WriteInFile()
        {
            string[]      NumOfFiles = new string[50];
            string[]      NumOfDir   = new string[50];
            DirectoryInfo dir        = new DirectoryInfo(@"C:\");

            Directory.CreateDirectory(@"D:\учеба\ООП\lab13\SDLInspect");
            StreamWriter dirfile = new StreamWriter(@"D:\учеба\ООП\lab13\SDLInspect\SDLdirinfo.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 SDLdirinfo.txt is created");
            SDLLog.OpenFile();

            SDLLog.OpenFile().WriteLine($"{DateTime.Now}\nCreating SDLdirinfo.txt\nPath: {dir.FullName}\n@");
        }
Ejemplo n.º 5
0
        public static void CopyAndRenameFile()
        {
            File.Copy(@"D:\учеба\ООП\lab13\SDLInspect\SDLdirinfo.txt", @"D:\учеба\ООП\lab13\SDLInspect\SDLdirinfoNew.txt");
            Console.WriteLine("File SDLdirinfo.txt is copied and renamed");

            SDLLog.OpenFile().WriteLine($"{DateTime.Now}\nCopying and renaming SDLdirinfo.txt\nPath: D:\\учеба\\ООП\\lab13\\SDLInspect\\SDLdirinfo.txt@");
        }
Ejemplo n.º 6
0
        public static void DeleteOldFile()
        {
            File.Delete(@"D:\учеба\ООП\lab13\SDLInspect\SDLdirinfo.txt");
            Console.WriteLine("File SDLdirinfo.txt is deleted");
            Console.WriteLine();

            SDLLog.OpenFile().WriteLine($"{DateTime.Now}\nDeleting old SDLdirinfo.txt\nPath: D:\\учеба\\ООП\\lab13\\SDLInspect\\SDLdirinfo.txt@");
        }
Ejemplo n.º 7
0
        public static void TimeInfo(string str)
        {
            Console.WriteLine("File created: " + File.GetCreationTime(str));
            Console.WriteLine("File changed: " + File.GetLastAccessTime(str));
            Console.WriteLine();

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

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

            SDLLog.OpenFile().WriteLine($"{DateTime.Now}\nChecking path to file\nFile name: {path}\nPath: {FullPath}\n@");
        }
Ejemplo 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}");
            SDLLog.OpenFile().WriteLine($"{DateTime.Now}\nChecking number of subdirectories\nPath: {dir.FullName}\n@");
            Console.WriteLine();
        }
Ejemplo n.º 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();

            SDLLog.OpenFile().WriteLine($"{DateTime.Now}\nChecking file size, extension and name\nFile name: {fileName}\nPath: {path}\n@");
        }
Ejemplo n.º 11
0
        public static void NewDir()
        {
            Directory.CreateDirectory(@"D:\учеба\ООП\lab13\SDLFiles");
            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\SDLFiles\" + x.Name);
                }
            }
            Console.WriteLine("New directory SDLFiles is created");

            SDLLog.OpenFile().WriteLine($"{DateTime.Now}\nCreating directory SDLFiles\nPath: {dir.FullName}\n@");
        }
Ejemplo n.º 12
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);
                }
            }

            SDLLog.OpenFile().WriteLine($"{DateTime.Now}\nScan file system\n@");
            Console.WriteLine();
        }
Ejemplo 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);
                }
            }

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

            SDLDiskInfo.PrintDiskInfo();
            SDLFileInfo.PrintFileInfo(@"D:\учеба\ООП\lab1\New.txt");
            SDLDirInfo.PrintDirInfo(new DirectoryInfo(@"D:\учеба\ООП"));
            SDLFileManager.PrintFileManager();
            SDLLog.CloseFile();

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