private void btn_download_Click(object sender, EventArgs e) { #region 载 if (listBox1.SelectedItem == null) { MsgBox.ShowInfoMsg("请选择下载的文档!"); } else { SaveFileDialog dlg = new SaveFileDialog(); dlg.FileName = (string)listBox1.SelectedItem; if (dlg.ShowDialog() == DialogResult.OK) { string filePath = dlg.FileName.Substring(0, dlg.FileName.LastIndexOf("\\")); Ftp ftp = FtpControl.GetFtp("WorkOrder/" + model.WOCode); string message = ftp.Download(filePath, (string)listBox1.SelectedItem); if (message == "") { message = "下载完成!"; } MessageBox.Show(message); } } #endregion }
private void GetFTPFileList(string path) { #region 获取FTP文件列表 var ftp = FtpControl.GetFtp("WorkOrder/"); if (ftp.FolderExist(model.WOCode)) { ftp = FtpControl.GetFtp("WorkOrder/" + model.WOCode); string[] sArray = ftp.GetFileList(); if (sArray != null && sArray.Length > 0) { this.listBox1.Items.Clear(); foreach (string s in sArray) { string[] sAry = s.Split(new char[] { ' ' }); this.listBox1.Items.Add(s); } } } #endregion }
private void btn_delfile_Click(object sender, EventArgs e) { #region 除文档 if (listBox1.SelectedItem == null) { MsgBox.ShowInfoMsg("请选择要删除的记录!"); } else if (MsgBox.ShowYesNoMsg("确定删除选中文档?") == DialogResult.Yes) { Ftp ftp = FtpControl.GetFtp("WorkOrder/" + model.WOCode); ftp.DeleteFileName((string)listBox1.SelectedItem); this.GetFTPFileList(model.WOCode); } #endregion }
private bool UpLoadFile(params string[] fileNames) { #region 图纸 if (fileNames.Length < 1) { MsgBox.ShowInfoMsg("选择需要上传的文件!"); return(false); } try { var ftp = FtpControl.GetFtp("WorkOrder/" + model.WOCode); foreach (string fileName in fileNames) { FileInfo file = new FileInfo(fileName); if (ftp.FileExist(file.Name)) { MsgBox.ShowInfoMsg("FTP已存在相同名称的文件:" + file.Name); return(false); } } foreach (string fileName in fileNames) { FileInfo file = new FileInfo(fileName); string message = ftp.Upload(file.FullName); if (message != "") { MsgBox.ShowInfoMsg(message); return(false); } } } catch (Exception ex) { MsgBox.ShowInfoMsg(ex.ToString()); return(false); } return(true); #endregion }