Beispiel #1
0
        private static void ProcessDirectory(FileManager mgr, string DirectoryName)
        {
            System.Console.WriteLine("Processing source directory {0}", DirectoryName); // TODO

            foreach (string ChildDirectory in Directory.EnumerateDirectories(DirectoryName))
            {
                ProcessDirectory(mgr, Path.Combine(DirectoryName, ChildDirectory));
            }

            foreach (string FileName in Directory.EnumerateFiles(DirectoryName))
            {
                List<string> DestFile = mgr.CheckForFile(Path.Combine(DirectoryName, FileName));
                if (DestFile == null)
                {
                    // System.Console.WriteLine("{0} doesn't exist in the dest directory!", FileName);
                }
                else
                {
                    //System.Console.WriteLine("{0} already exists in the dest directory as:", FileName);
                    //foreach (string FileHit in DestFile)
                    //{
                    //    System.Console.WriteLine("\t{0}", FileHit);
                    //}

                    System.Console.WriteLine("Sending file {0} to recycle bin (already exists as {1}) ...", FileName, DestFile.ElementAt(0));
                    FileSystem.DeleteFile(FileName, UIOption.OnlyErrorDialogs, RecycleOption.SendToRecycleBin);
                }
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                PrintUsage();
            }

            //Win32FileManager FileManager = new Win32FileManager();
            //IDirectory DestinationDirectory = FileManager.OpenDirectory(args.Last());

            //for (int i = 0; i < args.Length - 1; ++i)
            //{
            //    IDirectory Directory = FileManager.OpenDirectory(args[i]);

            //    Console.WriteLine("Moving {0} into {1}", args[i], DestinationDirectory);
            //    FileManager.EnumerateFiles(Directory, (File) => ProcessFile(Directory, DestinationDirectory, File));
            //}

            FileManager mgr = new FileManager(args.Last());

            if (!mgr.ProcessExistingFiles())
            {
                System.Console.WriteLine("Couldn't process files!");
                return; // TODO
            }

            for (int i = 0; i < args.Length - 1; ++i)
            {
                string DirectoryName = args[i];
                if (!Path.IsPathRooted(DirectoryName))
                {
                    string AbsolutePath = Path.Combine(Environment.CurrentDirectory, DirectoryName);
                    DirectoryName = AbsolutePath;
                }

                ProcessDirectory(mgr, DirectoryName);
            }
        }