//根据导入列表下载 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 }); } }
/// <summary> /// 根据订单 或右键下载 /// </summary> /// <param name="pathList">key:文件名,value:主题名</param> /// <param name="outFamate">导出格式</param> /// <param name="fileType">以什么为文件名,0文件名,1主题名,2主题文件夹</param> public void DownLoadFile(Dictionary<string, string> pathList, string outFamate, int fileType) { 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.Keys) { FileStatus myfile = fs.GetFileStatus(ConfigHelper.HdfsRoot + "/" + CurrentPath + "/" + filePath + outFamate); if (myfile != null) { myfile.FileName = pathList[filePath] + outFamate; 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 = fileType }); } }