public ActionResult Remove(string[] fileNames, string keyValue) { FTPHelper ftp = new FTPHelper(_FtpConnection.Value.FtpServerIP, _FtpConnection.Value.FtpRemotePath + "/tbz/" + keyValue, _FtpConnection.Value.FtpUserID, _FtpConnection.Value.FtpPassword); if (fileNames != null) { foreach (var fullName in fileNames) { try { ftp.Delete(fullName); using (var db = attachRepository.Connection) { attachRepository.DeleteFile(db, keyValue, fullName); } return(Success("删除成功!")); } catch (Exception ex) { return(Content(ex.Message)); } } } return(Content("")); }
private void btn_uplaod_Click(object sender, RoutedEventArgs e) { if (ismanager) { userfilename = file.fileName; } else { //注意: //如果是学生上传答卷 //请在这里定义上传文件的新名称,规则是添加时间戳+学号前缀,比如:20170227_2014309010124_ userfilename = DateTime.Now.ToString("yyyyMMdd") + "_" + StaticInform.Num + "_" + file.fileName; } if (btn_uplaod.Content.ToString() == "上传") { btn_uplaod.Content = "撤销"; upPro = new DownLoadProcess(FTP, file, "", userfilename); upPro.OnUpLoadComplete += new DownLoadProcess.DownloadStatusChangeHandle(upPro_OnUpLoadComplete); upPro.StartUpLoad(); } else { btn_uplaod.Content = "上传"; if (userfilename != null || userfilename != "") { file.complete = 0; FTP.Delete(userfilename); } } }
public static void DeleteFile(string type, string fileName) { FTPHelper ftp= new FTPHelper(cConfig.FTP_IP, cConfig.strFtpRoot, cConfig.FTP_user, cConfig.FTP_password); try { ftp.GotoDirectory(cConfig.strFtpRoot + "/" + type, true); ftp.Delete(fileName); } catch { } finally { if (ftp != null) ftp = null; } }
public static void DeleteFile(string type, string fileName) { FTPHelper ftp = new FTPHelper(cConfig.FTP_IP, cConfig.strFtpRoot, cConfig.FTP_user, cConfig.FTP_password); try { ftp.GotoDirectory(cConfig.strFtpRoot + "/" + type, true); ftp.Delete(fileName); } catch { } finally { if (ftp != null) { ftp = null; } } }
/// <summary> /// 删除所选文件 /// </summary> /// <param name="sender">传递对象</param> /// <param name="e">传递事件</param> private void btnDeleteFile_Click(object sender, EventArgs e) { if (null == _ftpHelper) { MessageBox.Show("请先创建FTP服务!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } lblStatusInfo.Text = "等待..."; string selectedFile = lstDataBox.SelectedItem as string; if (string.IsNullOrWhiteSpace(selectedFile)) { MessageBox.Show("您暂未选中任何文件,或列表中没有文件可供选择,请先执行获取基本列表,并确认选中了文件后重试。", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string resultString = _ftpHelper.Delete(selectedFile); lblStatusInfo.Text = $"{_ftpHelper.CurrentStatusCode} : {resultString}"; }
public ActionResult DelImg(string name, string keyValue) { FTPHelper ftp = new FTPHelper(_FtpConnection.Value.FtpServerIP, _FtpConnection.Value.FtpRemotePath + "/tzb/" + keyValue, _FtpConnection.Value.FtpUserID, _FtpConnection.Value.FtpPassword); if (name != "") { try { ftp.Delete(name); using (var db = attachRepository.Connection) { attachRepository.DeleteFile(db, keyValue, name); } return(Success("删除成功!")); } catch (Exception ex) { return(Content(ex.Message)); } } return(Content("")); }
public static void Tt() { FTPHelper ftp = new FTPHelper("10.221.167.49", "moldyun", "ycchen10", "Chyuch^011"); ftp.Delete("123.txt"); }