NetHadoop.FSClient.GetFileStatus C# (CSharp) Method

GetFileStatus() public method

public GetFileStatus ( string path ) : FileStatus
path string
return FileStatus
        public FileStatus GetFileStatus(string path)
        {
            TBufferedTransport tsport = null;
               ThriftHadoopFileSystem.Client client = Connect(out tsport);
               FileStatus result = null; //new List<FileStatus>();
               //客户端可连接 且目录存在
               if (client != null&& client.exists(new Pathname { pathname = path }))
               {
               result = client.stat(new Pathname() { pathname = path });
               tsport.Close();
               }
               return result;
        }

Usage Example

示例#1
0
        //根据导入列表下载
        public void DownLoadFile(List <string> pathList, string outFamate)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            fbd.ShowNewFolderButton = true;
            fbd.Description         = "请选择一个文件夹存放导出的视频文件。";

            //选择保存文件夹
            if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                worker.DoWork             += new DoWorkEventHandler(DoDownLoadWork);
                worker.ProgressChanged    += new ProgressChangedEventHandler(ProgessChanged);
                worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(CompleteDownLoadWork);

                List <FileStatus> fileList = new List <FileStatus>();

                FSClient      fs      = new FSClient();
                List <string> noFound = new List <string>();

                foreach (string filePath in pathList)
                {
                    FileStatus myfile = fs.GetFileStatus(ConfigHelper.HdfsRoot + "/" + CurrentPath + "/" + filePath + outFamate);
                    if (myfile != null)
                    {
                        fileList.Add(myfile);
                    }
                    else
                    {
                        noFound.Add(filePath);
                    }
                }
                string nofoundTitle = string.Format("以下{0}个文件没有找到,请核实:\r\n{1}\r\n===结束===", noFound.Count, string.Join("\r\n", noFound.ToArray()));
                File.WriteAllText(fbd.SelectedPath + "/NoFound.txt", nofoundTitle);

                worker.RunWorkerAsync(new DownloadArg()
                {
                    FileList = fileList, SavePath = fbd.SelectedPath, OutFileType = 0
                });
            }
        }
All Usage Examples Of NetHadoop.FSClient::GetFileStatus