Exemplo n.º 1
0
        //剪切
        public List <string> MoveFile(string[] sourcePath, string dectPath)
        {
            TBufferedTransport tsport = null;

            ThriftHadoopFileSystem.Client client = Connect(out tsport);
            List <string> result = new List <string>();

            if (client != null)
            {
                foreach (string itemSource in sourcePath)
                {
                    Pathname pn = new Pathname()
                    {
                        pathname = itemSource
                    };
                    string fileName = itemSource.Substring(itemSource.LastIndexOf('/') + 1);
                    if (client.exists(pn))//如果存在才执行
                    {
                        bool thResult = client.rename(pn, new Pathname()
                        {
                            pathname = dectPath + "/" + fileName
                        });
                        if (!thResult)
                        {
                            result.Add(fileName);
                        }
                    }
                }
                tsport.Close();
            }
            return(result);
        }
Exemplo n.º 2
0
        //重命名文件或文件夹
        public bool ReName(string oldPath, string newPath)
        {
            TBufferedTransport tsport = null;

            ThriftHadoopFileSystem.Client client = Connect(out tsport);
            bool result = false;

            if (client != null)
            {
                Pathname pn = new Pathname()
                {
                    pathname = oldPath
                };
                if (client.exists(pn))//如果存在才执行
                {
                    result = client.rename(pn, new Pathname()
                    {
                        pathname = newPath
                    });
                }

                tsport.Close();
            }
            return(result);
        }