NetHadoop.FSClient.MoveFile C# (CSharp) Method

MoveFile() public method

public MoveFile ( string sourcePath, string dectPath ) : List
sourcePath string
dectPath string
return List
        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;
        }

Usage Example

示例#1
0
 //粘贴
 private void MenuItemPaste_Click(object sender, EventArgs e)
 {
     if (pasterTemp.Count > 0)
     {
         FSClient      client  = new FSClient();
         List <string> noPaste = client.MoveFile(pasterTemp.ToArray(), ConfigHelper.HdfsRoot + CurrentPath);
         if (noPaste.Count > 0)
         {
             try
             {
                 File.WriteAllText("c:/NoPaste.txt", string.Join("\r\n", pasterTemp.ToArray()));
             }
             catch (Exception ee)
             {
                 logger.Error("粘贴错误", ee);
             }
             MessageBox.Show("有" + pasterTemp.Count + "个文件或文件夹没有粘贴成功!请查看c:/NoPaste.txt详细!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         //清除剪切板
         pasterTemp.Clear();
         //重新加载
         LoadFileStatus(CurrentPath);
     }
 }
All Usage Examples Of NetHadoop.FSClient::MoveFile