Beispiel #1
0
        public string ShowDirectory(string x)
        {
            Console.BackgroundColor = ConsoleColor.Black;
            Console.Clear();

            DirectoryInfo di = new DirectoryInfo(x);

            DirectoryInfo[] d = di.GetDirectories();
            FileInfo[]      f = di.GetFiles();
            Console.ForegroundColor = ConsoleColor.DarkYellow;
            for (int i = 0; i < d.Length; i++)
            {
                Console.SetCursorPosition(4, i);
                Console.WriteLine(d[i]);
            }
            Console.ForegroundColor = ConsoleColor.Blue;
            for (int i = 0; i < f.Length; i++)
            {
                Console.SetCursorPosition(4, i + d.Length);
                Console.WriteLine(f[i]);
            }
            Console.ForegroundColor = ConsoleColor.Red;
            Console.SetCursorPosition(4, d.Length + f.Length);
            Console.WriteLine("Back");
            Console.ForegroundColor = ConsoleColor.Gray;

            Console.ForegroundColor = ConsoleColor.Green;
            Console.SetCursorPosition(4, d.Length + f.Length + 1);
            Console.WriteLine("OK");
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.BackgroundColor = ConsoleColor.White;
            Console.SetCursorPosition(1, cursor);
            Console.Write("  ");
            ConsoleKey key = Console.ReadKey().Key;

            switch (key)
            {
            case ConsoleKey.Enter:
                if (Console.CursorTop == (d.Length + f.Length + 1))
                {
                    File.Delete("CopyLocation.txt");
                    StreamWriter sw = new StreamWriter("CopyLocation.txt");
                    sw.Write(Convert.ToString(x));
                    sw.Close();
                    Home.HomePage();
                }

                if (Console.CursorTop == d.Length + f.Length)
                {
                    return(" ");
                }
                if (Console.CursorTop < d.Length)
                {
                    Directory m = new Directory();
                    m.ShowDirectory(Convert.ToString(d[Console.CursorTop].FullName));
                }
                if (Console.CursorTop >= d.Length && Console.CursorTop < f.Length)
                {
                    Process.Start(Convert.ToString(f[Console.CursorTop].FullName));
                }
                break;

            case ConsoleKey.UpArrow:
                if (Console.CursorTop == 0)
                {
                    cursor = d.Length + f.Length + 1;
                }
                else
                {
                    cursor -= 1;
                }
                break;

            case ConsoleKey.DownArrow:
                if (Console.CursorTop == d.Length + f.Length + 1)
                {
                    cursor = 0;
                }
                else
                {
                    cursor += 1;
                }
                break;
            }

            ShowDirectory(x);
            return("");
        }
Beispiel #2
0
        public static void HomePage()
        {
            Console.CursorVisible = false;
            Drive d = new Drive();

            Console.BackgroundColor = ConsoleColor.DarkCyan;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.Clear();
            Console.SetCursorPosition(50, 8);
            if (cursor == Console.CursorTop)
            {
                Console.ForegroundColor = ConsoleColor.White;
            }
            Console.WriteLine("Copy This Session");
            Console.ForegroundColor = ConsoleColor.Black;

            Console.SetCursorPosition(50, 11);
            if (cursor == Console.CursorTop)
            {
                Console.ForegroundColor = ConsoleColor.White;
            }
            Console.WriteLine("Special Copy");
            Console.ForegroundColor = ConsoleColor.Black;
            Console.SetCursorPosition(50, 14);
            if (cursor == Console.CursorTop)
            {
                Console.ForegroundColor = ConsoleColor.White;
            }
            Console.WriteLine("Select Source Folder");
            Console.ForegroundColor = ConsoleColor.Black;
            Console.SetCursorPosition(50, 17);
            if (cursor == Console.CursorTop)
            {
                Console.ForegroundColor = ConsoleColor.White;
            }
            Console.WriteLine("Exit");
            Console.ForegroundColor = ConsoleColor.Black;
            Console.BackgroundColor = ConsoleColor.White;
            Console.SetCursorPosition(47, cursor);
            Console.Write("  ");


            ConsoleKey key = Console.ReadKey().Key;

            switch (key)
            {
            case ConsoleKey.Enter:
                if (Console.CursorTop == 8)
                {
                    if (File.Exists("CopyLocation.txt"))
                    {
                        StreamReader    sr     = new StreamReader("CopyLocation.txt");
                        DirectoryInfo   di     = new DirectoryInfo(Convert.ToString(sr.ReadLine()));
                        DirectoryInfo[] direct = di.GetDirectories();
                        FileInfo[]      f      = di.GetFiles();
                        DriveInfo[]     drive  = DriveInfo.GetDrives();
                        string[]        show   = new string[drive.Length];
                        for (int i = 0; i < drive.Length; i++)
                        {
                            if (drive[i].IsReady)
                            {
                                if (Convert.ToString(drive[i].DriveType) == "Removable")
                                {
                                    for (int j = 0; j < f.Length; j++)
                                    {
                                        if ((f[j].LastWriteTime).Year == DateTime.Now.Year)
                                        {
                                            if ((f[j].LastWriteTime).Month == DateTime.Now.Month)
                                            {
                                                if ((f[j].LastWriteTime).Day == DateTime.Now.Day)
                                                {
                                                    if (f[j].Length < drive[i].TotalFreeSpace)
                                                    {
                                                        double a = drive[i].TotalFreeSpace;
                                                        File.Copy(Convert.ToString(f[j].FullName), $"{Convert.ToString(drive[i])}" +
                                                                  $"\\{f[j].Name}", true);
                                                        if (a > drive[i].TotalFreeSpace)
                                                        {
                                                            show[i] = drive[i].Name + " Transfer Successfuly";
                                                        }
                                                        else
                                                        {
                                                            if (f[j].Length > drive[i].TotalFreeSpace)
                                                            {
                                                                show[i] = drive[i].Name + " Not Enough Storage Space";
                                                            }
                                                            else
                                                            {
                                                                show[i] = drive[i].Name + " Transfer Failed";
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        string finalshow = "\n\n\n\n\n\n\n\n";
                        for (int i = 0; i < drive.Length; i++)
                        {
                            if (drive[i].IsReady)
                            {
                                if (Convert.ToString(drive[i].DriveType) == "Removable")
                                {
                                    finalshow += $"\t\t\t\t\t\t{show[i]}\n\n\n";
                                    Console.Clear();
                                }
                            }
                        }
                        Console.BackgroundColor = ConsoleColor.Gray;
                        Console.Clear();

                        Console.ForegroundColor = ConsoleColor.DarkMagenta;

                        Console.WriteLine(finalshow);
                        Console.ForegroundColor = ConsoleColor.Gray;
                        Console.ReadKey();
                        Home.HomePage();
                    }
                    else
                    {
                        Console.BackgroundColor = ConsoleColor.Black;
                        Console.Clear();

                        Console.ForegroundColor = ConsoleColor.DarkRed;
                        Console.SetCursorPosition(49, 10);
                        Console.WriteLine(" Not Found Adress");
                        Console.SetCursorPosition(49, 12);
                        Console.WriteLine("Please Set Adress");
                        Console.ForegroundColor = ConsoleColor.Gray;
                        Console.ReadKey();
                        HomePage();
                    }
                }
                if (Console.CursorTop == 11)
                {
                    Special.Copy();
                }
                if (Console.CursorTop == 14)
                {
                    d.ShowDrives();
                }
                else
                {
                    Environment.Exit(0);
                }
                break;

            case ConsoleKey.UpArrow:
                if (Console.CursorTop == 8)
                {
                    cursor = 17;
                }
                else
                {
                    cursor -= 3;
                }
                break;

            case ConsoleKey.DownArrow:
                if (Console.CursorTop == 17)
                {
                    cursor = 8;
                }
                else
                {
                    cursor += 3;
                }
                break;
            }
            HomePage();
        }
Beispiel #3
0
 static void Main(string[] args)
 {
     Home.HomePage();
 }