예제 #1
0
        public static void CreateDirectory(string path)
        {
            var dirInf1 = new DirectoryInfo(path);

            dirInf1.Create();
            Success?.Invoke($"{dirInf1.FullName} созданa!");
        }
예제 #2
0
        public static void DeleteFile(string path)
        {
            var fileInf2 = new FileInfo(path);

            fileInf2.Delete();
            Success?.Invoke($"Фаил {fileInf2.FullName} удалён!");
        }
예제 #3
0
        public static void DeleteDirectory(string path)
        {
            var logger = new LogToFile();

            Error   += LogToConsole.Error;
            Error   += logger.Error;
            Info    += LogToConsole.Info;
            Info    += logger.Info;
            Success += LogToConsole.Successfully;
            Success += logger.Successfully;

            try
            {
                var dirInfo2 = new DirectoryInfo(path);
                if (!dirInfo2.Exists)
                {
                    return;
                }
                dirInfo2.Delete(true);
                Success?.Invoke($"Каталог {dirInfo2.FullName} удален");
            }
            catch (UnauthorizedAccessException ex)
            {
                Error?.Invoke(ex.Message);
            }
        }
예제 #4
0
        public static void CopyDir(string path1, string path2)
        {
            var dirInf3 = new DirectoryInfo(path1);

            if (!dirInf3.Exists || Directory.Exists(path2) != false)
            {
                return;
            }
            dirInf3.MoveTo(path2);
            Success?.Invoke($"Каталог скопирован в {dirInf3.FullName}");
        }
예제 #5
0
        public static void CopyFile(string path1, string path2)
        {
            var fileInf3 = new FileInfo(path1);

            if (!fileInf3.Exists)
            {
                return;
            }
            fileInf3.CopyTo(path2, true);
            Success?.Invoke($"Фаил скопирован в {fileInf3.FullName}");
        }
예제 #6
0
        public static void CreateFile(string path)
        {
            var logger = new LogToFile();

            Error   += LogToConsole.Error;
            Error   += logger.Error;
            Info    += LogToConsole.Info;
            Info    += logger.Info;
            Success += LogToConsole.Successfully;
            Success += logger.Successfully;

            using var fileInf1 = File.Create(path);
            Success?.Invoke($"{fileInf1.Name} создан!");
        }
예제 #7
0
        public static void CreateDirectory(string path)
        {
            var logger = new LogToFile();

            Error   += LogToConsole.Error;
            Error   += logger.Error;
            Info    += LogToConsole.Info;
            Info    += logger.Info;
            Success += LogToConsole.Successfully;
            Success += logger.Successfully;

            var dirInf1 = new DirectoryInfo(path);

            dirInf1.Create();
            Success?.Invoke($"{dirInf1.FullName} созданa!");
        }
예제 #8
0
        public static void DeleteFile(string path)
        {
            var logger = new LogToFile();

            Error   += LogToConsole.Error;
            Error   += logger.Error;
            Info    += LogToConsole.Info;
            Info    += logger.Info;
            Success += LogToConsole.Successfully;
            Success += logger.Successfully;

            var fileInf2 = new FileInfo(path);

            fileInf2.Delete();
            Success?.Invoke($"Фаил {fileInf2.FullName} удалён!");
        }
예제 #9
0
 public static void DeleteDirectory(string path)
 {
     try
     {
         var dirInfo2 = new DirectoryInfo(path);
         if (!dirInfo2.Exists)
         {
             return;
         }
         dirInfo2.Delete(true);
         Success?.Invoke($"Каталог {dirInfo2.FullName} удален");
     }
     catch (UnauthorizedAccessException ex)
     {
         Error?.Invoke(ex.Message);
     }
 }
예제 #10
0
        public static void CopyDir(string path1, string path2)
        {
            var logger = new LogToFile();

            Error   += LogToConsole.Error;
            Error   += logger.Error;
            Info    += LogToConsole.Info;
            Info    += logger.Info;
            Success += LogToConsole.Successfully;
            Success += logger.Successfully;

            var dirInf3 = new DirectoryInfo(path1);

            if (!dirInf3.Exists || Directory.Exists(path2) != false)
            {
                return;
            }
            dirInf3.MoveTo(path2);
            Success?.Invoke($"Каталог скопирован в {dirInf3.FullName}");
        }
예제 #11
0
        public static void CopyFile(string path1, string path2)
        {
            var logger = new LogToFile();

            Error   += LogToConsole.Error;
            Error   += logger.Error;
            Info    += LogToConsole.Info;
            Info    += logger.Info;
            Success += LogToConsole.Successfully;
            Success += logger.Successfully;

            var fileInf3 = new FileInfo(path1);

            if (!fileInf3.Exists)
            {
                return;
            }
            fileInf3.CopyTo(path2, true);
            Success?.Invoke($"Фаил скопирован в {fileInf3.FullName}");
        }
예제 #12
0
 public static void CreateFile(string path)
 {
     using var fileInf1 = File.Create(path);
     Success?.Invoke($"{fileInf1.Name} создан!");
 }