Exemplo n.º 1
0
        public string DeleteFile(string directory)
        {
            Json      checkfile  = new Json();
            CheckPath check_path = new CheckPath();


            if (directory.Contains(" "))
            {
                response = "File Cannot Contain Spaces!";
            }
            else if (check_path.directoryexists(@"C:\COSMOS") == false || directory == "/" || directory == @"\")//check if destination exist
            {
                response = "Input Cannot be a Directory!";
            }
            else if (checkfile.checkfile(directory) == false || directory == "." || directory == @"\" || directory == "/")//check if file exists
            {
                response = "File Not found";
            }
            else
            {
                Process.Start("cmd", @"/c cd C:\hadoop-2.7.2\bin && hdfs dfs -rm /" + directory).WaitForExit();

                response = "File Deleted!";
            }



            return(response);
        }
Exemplo n.º 2
0
        public string GetFile(string directory)
        {
            Json      checkfile  = new Json();
            CheckPath check_path = new CheckPath();

            DirectoryInfo dir = new DirectoryInfo(@"C:\COSMOS");


            ////If the File being downloaded exsits.. Delete the file//////
            if (System.IO.File.Exists(@"C:\COSMOS\" + directory))
            {
                System.IO.File.Delete(@"C:\COSMOS\" + directory);
            }



            if (directory.Contains(" "))
            {
                response = "File Directory Contains Space!";
            }
            else if (check_path.directoryexists(@"C:\COSMOS") == false || directory == "/" || directory == @"\")//check if destination exist
            {
                response = "The Directory Doesn't Exist!";
            }
            else if (checkfile.checkfile(directory) == false || directory == "." || directory == @"\" || directory == "/")//check if file exists
            {
                response = "File Not found";
            }
            else if (checkfile.isfileCorrupt(directory))
            {
                response = "File is Corrupted!";
            }
            else
            {
                Process.Start("cmd", @"/c cd C:\hadoop-2.7.2\bin && hdfs dfs -copyToLocal /" + directory + @" C:\COSMOS").WaitForExit();


                if (check_path.local_file_incomplete(directory, @"C:\COSMOS"))
                {
                    response = "File Download was cancelled upon download!";
                }
                else
                {
                    response = "File downloaded";
                }
            }



            return(response);
        }