static public void CopyFilesFromTo(string originDir, string newDir, string extension)
        {
            if (!Directory.Exists(originDir))
            {
                Console.WriteLine($"{originDir} not found :c");
                return;
            }

            if (!Directory.Exists(originDir))
            {
                CreateDirectory(newDir);
            }


            var OD      = new DirectoryInfo(originDir);
            var ODfiles = OD.GetFiles();

            foreach (var item in ODfiles)
            {
                string name = Path.Combine(newDir, item.Name);
                if (item.Extension == extension)
                {
                    if (!File.Exists(name))
                    {
                        item.CopyTo(name);
                    }
                }
            }

            PMNLog.WriteLog($"CopyFilesFromTo(\"{originDir}\", \"{newDir}\", \"{extension}\")");
        }
Beispiel #2
0
        static public void WriteFreeDiskSpace()
        {
            var disks = DriveInfo.GetDrives();

            Console.WriteLine("+Disk Name:\t\tFree Space:");
            foreach (var disk in disks)
            {
                Console.WriteLine($"{disk.Name, 9}\t\t {disk.AvailableFreeSpace/1e9:F2} GB");
            }

            PMNLog.WriteLog($"WriteFreeDiskSpace()");
        }
Beispiel #3
0
        static public void WriteDriverFormat()
        {
            var disks = DriveInfo.GetDrives();

            Console.WriteLine("+Disk Name:\t\tDrive Format:");
            foreach (var disk in disks)
            {
                Console.WriteLine($"{disk.Name,9}\t\t    {disk.DriveFormat, 8}");
            }

            PMNLog.WriteLog($"WriteDriverFormat()");
        }
Beispiel #4
0
        static public void WriteAllDiskInfo()
        {
            var disks = DriveInfo.GetDrives();

            Console.WriteLine("+Disk Name:\t\tTotal size:\t\tFree Space:");
            foreach (var disk in disks)
            {
                Console.WriteLine($"{disk.Name,9}\t\t {disk.TotalSize/1e9:F2} GB\t\t {disk.TotalFreeSpace/1e9:F2} GB");
            }

            PMNLog.WriteLog($"WriteAllDiskInfo()");
        }
        static public void DeleteFile(string path)
        {
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            else
            {
                Console.WriteLine($"File {path} not found!");
            }

            PMNLog.WriteLog($"DeleteFile(\"{path}\")");
        }
        static public void CopyFile(string originPath, string newPath)
        {
            if (File.Exists(newPath))
            {
                Console.WriteLine($"File {originPath} already exist!");
            }
            else
            {
                File.Copy(originPath, newPath);
            }

            PMNLog.WriteLog($"CreateFile(\"{originPath}\", \"{newPath}\")");
        }
        static public void CreateFile(string path)
        {
            if (File.Exists(path))
            {
                Console.WriteLine($"File {path} already exist!");
            }
            else
            {
                File.Create(path);
            }

            PMNLog.WriteLog($"CreateFile(\"{path}\")");
        }
        static public void CreateDirectory(string path)
        {
            if (Directory.Exists(path))
            {
                Console.WriteLine($"Directory {path} already exist!");
            }
            else
            {
                Directory.CreateDirectory(path);
            }

            PMNLog.WriteLog($"CreateDirectory(\"{path}\")");
        }
        static public void SaveStringInFile(string path, string Data)
        {
            if (!File.Exists(path))
            {
                return;
            }
            using (StreamWriter sw = new StreamWriter(path))
            {
                sw.WriteLine(Data);
            }

            PMNLog.WriteLog($"SaveStringInFile(\"{path}\", \"{Data}\")");
        }
Beispiel #10
0
        public void WriteCountOfFiles()
        {
            if (_directory.Exists)
            {
                Console.WriteLine($"+Count of Files in {_directory.Name}: {_directory.GetFiles().Length}");
            }
            else
            {
                Console.WriteLine($"Directory: {_directory.Name} not found unfortunely :c");
            }

            PMNLog.WriteLog($"WriteCountOfFiles()");
        }
Beispiel #11
0
        public void WriteFileInfo()
        {
            if (this._file.Exists)
            {
                Console.WriteLine($"+File name: {this._file.Name}\nFile extension: {this._file.Extension}\nFile size: {this._file.Length} byte");
            }
            else
            {
                Console.WriteLine($"File {this._file.FullName} not found unfortunately :c");
            }

            PMNLog.WriteLog($"WriteFileInfo()");
        }
Beispiel #12
0
        public void WriteCreationTime()
        {
            if (this._file.Exists)
            {
                Console.WriteLine($"+Creation time: {File.GetCreationTimeUtc(this._file.FullName)}");
            }
            else
            {
                Console.WriteLine($"File {this._file.FullName} not found unfortunately :c");
            }

            PMNLog.WriteLog($"WriteCreationTime()");
        }
Beispiel #13
0
        public void WriteFilePath()
        {
            if (this._file.Exists)
            {
                Console.WriteLine($"+File namme: {this._file.Name}\nFile path: {this._file.FullName}");
            }
            else
            {
                Console.WriteLine($"File {this._file.FullName} not found unfortunately :c");
            }

            PMNLog.WriteLog($"WriteFilePath()");
        }
Beispiel #14
0
        public void WriteCountOfSubdirectories()
        {
            if (this._directory.Exists)
            {
                Console.WriteLine($"+Count of Subdirectories in {_directory.Name}: {_directory.GetDirectories().Length}");
            }
            else
            {
                Console.WriteLine($"Directory {this._directory.Name} not found unfortunately :c");
            }

            PMNLog.WriteLog($"WriteCountOfSubdirectories()");
        }
Beispiel #15
0
        public void WriteCreationTime()
        {
            if (this._directory.Exists)
            {
                Console.WriteLine($"+{this._directory.Name} Creation time: {Directory.GetCreationTimeUtc(this._directory.FullName)}");
            }
            else
            {
                Console.WriteLine($"Directory {this._directory.Name} not found unfortunately :c");
            }

            PMNLog.WriteLog($"WriteCreationTime()");
        }
        static public string ReadAllInformationFromFile(string path)
        {
            if (!File.Exists(path))
            {
                Console.WriteLine($"File {path} not found :c");
                PMNLog.WriteLog($"ReadAllInformationFromFile(\"{path}\") - File not found");
                return(null);
            }

            using (StreamReader sr = new StreamReader(path))
            {
                return(sr.ReadToEnd());
            }

            PMNLog.WriteLog($"ReadAllInformationFromFile(\"{path}\")");
        }
Beispiel #17
0
        public void WriteListOfParentDirectories()
        {
            if (this._directory.Exists)
            {
                var directories = _directory.Parent.GetDirectories();
                Console.WriteLine($"+{_directory.Parent.Name} Subdirectories: ");
                foreach (var dir in directories)
                {
                    Console.WriteLine(dir.Name);
                }
            }
            else
            {
                Console.WriteLine($"Directory {this._directory.Name} not found unfortunately :c");
            }

            PMNLog.WriteLog($"WriteListOfParentDirectories()");
        }
        static public void WriteListOfFilesAndDirectories(string path)
        {
            Console.WriteLine($"Disk Name: {path}");
            Console.WriteLine("Directories: ");
            var directories = Directory.GetDirectories(path);

            foreach (var item in directories)
            {
                Console.WriteLine($"\t{item}");
            }

            Console.WriteLine("Files: ");
            var files = Directory.GetFiles(path);

            foreach (var item in files)
            {
                Console.WriteLine($"\t{item}");
            }

            PMNLog.WriteLog($"WriteListOfFilesAndDirectories(\"{path}\")");
        }
        static public void CreateArchive(string originPath, string zipPath)
        {
            ZipFile.CreateFromDirectory(originPath, zipPath);

            PMNLog.WriteLog($"CreateArchive(\"{originPath}\", \"{zipPath}\")");
        }
        static public void UnArchive(string zipPath, string newPath)
        {
            ZipFile.ExtractToDirectory(zipPath, newPath);

            PMNLog.WriteLog($"UnArchive(\"{zipPath}\", \"{newPath}\")");
        }