Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            PVPLog      logger = new PVPLog();
            PVPFileInfo file   = new PVPFileInfo(@"C:\PWL\study\OOP\lab13\pvp_log.txt");

            PVPFileManager.Task(@"C:\", @"C:\PWL\txt", ".txt"); // запускать очень осторожно, не забыв про создание файлов в txt, удаление zip
            logger.Write(PVPDirInfo.GetCountParentDirectories(@"C:\PWL"));
            logger.Write(PVPDirInfo.GetCountSubDirectories(@"C:\PWL"));
            logger.Write(PVPDirInfo.GetCountFiles(@"C:\PWL"));
            logger.Write(PVPDirInfo.GetCreationTime(@"C:\PWL"));
            logger.Write(PVPDiskInfo.GetFreeSpace("C:\\"));
            logger.Write(PVPDiskInfo.GetFileSystem("E:\\"));
            logger.Write(PVPDiskInfo.GetAllInfo());
            logger.Write(file.GetFullPath());
            logger.Write(file.GetFileInfo());
            logger.Write(file.GetCreationTime());
            logger.Find("18");
        }
Ejemplo n.º 2
0
        public static void Task(string drive, string user_dir, string user_ex)
        {
            string       list    = (PVPDirInfo.GetCountSubDirectories(drive) + "\n" + PVPDirInfo.GetCountFiles(drive));
            string       dir     = Convert.ToString(Directory.CreateDirectory(@"C:\PWL\study\OOP\lab13\PVPInspect"));
            StreamWriter fwriter = new StreamWriter(dir + "\\pvpdirinfo.txt", true, System.Text.Encoding.Default);

            fwriter.Write(list);
            fwriter.Close();
            FileInfo file = new FileInfo(dir + "\\pvpdirinfo.txt");

            if (file.Exists)
            {
                file.CopyTo(dir + "\\pvpdirinfonew.txt", true);
                file.Delete();
            }
            string newDir = Convert.ToString(Directory.CreateDirectory(@"C:\PWL\work_file"));

            string[] dirs = Directory.GetFiles(user_dir);
            for (int i = 0; i < dirs.Length; i++)
            {
                if (dirs[i].Contains(user_ex))
                {
                    string   path    = dirs[i];
                    FileInfo fileInf = new FileInfo(path);
                    if (fileInf.Exists)
                    {
                        dirs[i] = dirs[i].Remove(0, 11);
                        fileInf.MoveTo(@"C:\PWL\work_file\" + dirs[i]);
                    }
                }
            }
            string oldPath = @"C:\PWL\work_file";

            dir += "\\pvpfiles";
            Directory.Move(oldPath, dir);
            string zip     = @"C:\PWL\result.zip";
            string extract = @"C:\PWL\study\OOP\lab13\extract";

            ZipFile.CreateFromDirectory(dir, zip);
            ZipFile.ExtractToDirectory(zip, extract);
        }