Beispiel #1
0
        public int copy(string targetDir)
        {
            string[] tokens   = this.Path.Split(new char[] { '/', '\\' });
            string   fileName = tokens.Last();

            Directory backupDir = new Directory(targetDir);

            if (!backupDir.exists())
            {
                backupDir.createDirectory();
            }

            try
            {
                System.IO.File.Copy(this.Path, targetDir + "/" + fileName, true);
                return(1);
            }
            catch (Exception e)
            {
                Trace.TraceError(e.Message);
                return(-1);
            }
        }
Beispiel #2
0
        public static void doOperation(int choice)
        {
            switch (choice)
            {
            case 1:
                if (virtualDir.exists())
                {
                    Console.WriteLine("Directory exist on file system");
                }
                else
                {
                    Console.WriteLine("Directory does not exist on file system!");
                }
                break;

            case 2:
                int createResult = virtualDir.createDirectory();
                if (createResult == 0)
                {
                    Console.WriteLine("Directory already exists on file system!");
                }
                else if (createResult == -1)
                {
                    Console.WriteLine("Some problem occured during directory creation!");
                }
                else
                {
                    Console.WriteLine("Directory created on file system");
                }
                break;

            case 3:
                int delResult = virtualDir.deleteDirectory(true);
                if (delResult == 0)
                {
                    Console.WriteLine("Directory not exists on file system!");
                }
                else if (delResult == -1)
                {
                    Console.WriteLine("Some problem occured during deletion!");
                }
                else
                {
                    Console.WriteLine("Directory deleted from file system");
                }
                break;

            case 4:
                Console.WriteLine(virtualDir.getInfo());
                break;

            case 5:
                virtualDir.attachListener();
                break;

            case 6:
                virtualDir.SetPath(getPath());
                Console.WriteLine("Directory path changed!\n");
                break;

            case 7:
                Environment.Exit(0);
                break;

            default:
                Console.WriteLine("Invalid Choice!\n");
                displayInstructions();
                break;
            }
        }