private void deleteOldPDF(string date, string typ) { var expdate = Convert.ToDateTime(date).AddDays(-7); var result = db.ar_reqlist.Where(s => s.exprtn.Equals(date)).ToList <ar_reqlist>(); var xftp = new ftp(@"ftp://188.121.43.20/services.danubeco.com/ranking/", ""); foreach (var item in result) { try { if (item.rtype.Equals(typ)) { xftp.delete(Path.GetFileName(item.lnk)); _sysLog("FTP File " + item + " : deleted..", Color.Green, StatusType.Sys); } } catch (Exception) { _sysLog("FTP File " + item + " : error..", Color.Red, StatusType.Err); } } }
private void btnDeleteFile_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) { System.Data.DataRow dtR_rowLocal = grvAttachment.GetDataRow(grvAttachment.FocusedRowHandle); string str_ProjectIDLocal = this.str_ProjectIDGlobal;; string str_StageLocal = this.str_StageGlobal; string str_TaskLocal = this.str_TaskGlobal; string str_DateTime = dtR_rowLocal[0].ToString().Trim(); string str_FileName = dtR_rowLocal[1].ToString().Trim(); DialogResult dr = XtraMessageBox.Show("Are you sure you want delete file " + str_FileName + "?", "Confirm delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (dr == DialogResult.OK) { ftp ftpClientLocal = new ftp(StaticVarClass.ftp_Server, StaticVarClass.ftp_Username, StaticVarClass.ftp_Password); if (ftpClientLocal.delete(StaticVarClass.account_Username, str_FileName)) { if (AttachedFileDAO.Instance.deleteData(str_ProjectIDLocal, str_StageLocal, str_TaskLocal, str_DateTime)) { this.loadDataAttachFile(); XtraMessageBox.Show("Successfully deleted file " + str_FileName + " !", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { XtraMessageBox.Show("Delete file " + str_FileName + " failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { XtraMessageBox.Show("Delete file " + str_FileName + " failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public void DeleteFileFromUploads(string filename) { ftp ftpClient = new ftp("ftp://xo2.x10hosting.com/public_html/Uploads/", "dioramaw", "1qaz@WSX3edc$RFV"); ftpClient.delete(filename); ftpClient = null; }
private void recursiveDirectory(string dirPath, string uploadPath, ftp ftpClient) { string[] files = Directory.GetFiles(dirPath, "*.*"); string[] subDirs = Directory.GetDirectories(dirPath); foreach (string file in files) { string dateCreat = ftpClient.getFileCreatedDateTime(uploadPath + "/" + Path.GetFileName(file)); if (dateCreat != File.GetCreationTime(file).ToString()) { ftpClient.delete(uploadPath + "/" + Path.GetFileName(file)); logs = ftpClient.upload(uploadPath + "/" + Path.GetFileName(file), file); } else { //logs = ftpClient.upload(uploadPath + "/" + Path.GetFileName(file), file); } textBox8.Text += logs + Environment.NewLine; saveLog(logs); logs = ""; } foreach (string subDir in subDirs) { ftpClient.createDirectory(uploadPath + "/" + Path.GetFileName(subDir)); recursiveDirectory(subDir, uploadPath + "/" + Path.GetFileName(subDir), ftpClient); } }
private void deleteOldPDF(string date) { dnbmssqlEntities db = new dnbmssqlEntities(); var expdate = Convert.ToDateTime(date).AddDays(-7); var yeExp = expdate.ToString("yyyyMMdd"); var result = db.ar_po.Where(s => s.expiration.Equals(date)).ToList <ar_po>(); var xftp = new ftp(@"ftp://188.121.43.20/services.danubeco.com/supplier/", ""); foreach (var item in result) { try { xftp.delete(Path.GetFileName(item.link)); _sysLog("FTP File " + item + " : deleted..", Color.Green, StatusType.Sys); } catch (Exception) { _sysLog("FTP File " + item + " : error..", Color.Red, StatusType.Err); } } }
string pegaArq() { String ftpServerIP = ConfigurationManager.AppSettings["ftpServerIP"]; String ftpUserID = ConfigurationManager.AppSettings["ftpUserID"]; String ftpPassword = ConfigurationManager.AppSettings["ftpPassword"]; /* Create Object Instance */ // ftp ftpClient = new ftp(@"ftp://10.10.10.10/", "user", "password"); ftp ftpClient = new ftp(ftpServerIP, ftpUserID, ftpPassword); /* Upload a File */ ftpClient.upload("etc/test.txt", @"C:\Users\metastruct\Desktop\test.txt"); /* Download a File */ ftpClient.download("etc/test.txt", @"C:\Users\metastruct\Desktop\test.txt"); /* Delete a File */ ftpClient.delete("etc/test.txt"); /* Rename a File */ ftpClient.rename("etc/test.txt", "test2.txt"); /* Create a New Directory */ ftpClient.createDirectory("etc/test"); /* Get the Date/Time a File was Created */ string fileDateTime = ftpClient.getFileCreatedDateTime("etc/test.txt"); Console.WriteLine(fileDateTime); /* Get the Size of a File */ string fileSize = ftpClient.getFileSize("etc/test.txt"); Console.WriteLine(fileSize); /* Get Contents of a Directory (Names Only) */ string[] simpleDirectoryListing = ftpClient.directoryListDetailed("/etc"); for (int i = 0; i < simpleDirectoryListing.Count(); i++) { Console.WriteLine(simpleDirectoryListing[i]); } /* Get Contents of a Directory with Detailed File/Directory Info */ string[] detailDirectoryListing = ftpClient.directoryListDetailed("/etc"); for (int i = 0; i < detailDirectoryListing.Count(); i++) { Console.WriteLine(detailDirectoryListing[i]); } /* Release Resources */ ftpClient = null; return("ok"); }
/// <summary> /// upload file to xbox by FTP /// </summary> /// <param name="filepath"></param> private void ftp_file_2_xbox(string filepath) { // return if no JSRF file is currently loaded in the JSRF tool if (filepath == "") { return; } // return if one or mutiple FTP settings are undefined if ((txtb_xbox_debug_ip.Text == "") || (txtb_xbox_login.Text == "") || (txtb_xbox_pass.Text == "")) { MessageBox.Show("Please make sure the Xbox FTP IP, login and password are defined in the settings tab."); return; } // create ftp client with xbox login/password defined in Settings tab ftp ftpClient = new ftp(@"ftp:// " + txtb_xbox_debug_ip.Text + "/", txtb_xbox_login.Text, txtb_xbox_pass.Text); string subFolfder = ""; int split_dir_at = 0; string[] folders = filepath.Split(Path.DirectorySeparatorChar); // find the "Media" folder in path and substract the parent folders from it for (int i = 0; i < folders.Length; i++) { if (folders[i] == "Media") { split_dir_at = i; } } for (int i = split_dir_at + 1; i < folders.Length; i++) { subFolfder = subFolfder + "\\" + folders[i]; } ftpClient.upload((txtb_xbox_jsrf_dir.Text.TrimEnd(Path.DirectorySeparatorChar) + subFolfder).Replace("\\", "/"), filepath); // delete file from cache (so the game will reload the new modded file we just uploaded) ftpClient.delete("X:/Media/Mark/TEX/"); ftpClient.delete("Y:/Media/Mark/TEX/"); ftpClient.delete("Z:/Media/Mark/TEX/"); }
private void btnTestFTP_Click(object sender, EventArgs e) { btnTestFTP_change(sender, null); if (btnTestFTP.Enabled) { btnTestFTP.ForeColor = Color.Red; try { string fileName = "test.csv"; File.WriteAllText(fileName, "TEST"); ftp myFTP = new ftp(txbFTPServer.Text, txbFTPUserName.Text, txbFTPPassword.Text); if (myFTP.upload(fileName, fileName)) if (myFTP.delete(fileName)) btnTestFTP.ForeColor = Color.Green; } catch {} txbFTPServer.ForeColor = btnTestFTP.ForeColor; txbFTPUserName.ForeColor = btnTestFTP.ForeColor; txbFTPPassword.ForeColor = btnTestFTP.ForeColor; } }
// send graffiti file to xbox private void btn_send_to_xbox_Click(object sender, EventArgs e) { // return if one or mutiple FTP settings are undefined if ((txtb_xbox_debug_ip.Text == "") || (txtb_xbox_login.Text == "") || (txtb_xbox_pass.Text == "")) { MessageBox.Show("Please make sure the Xbox FTP IP, login and password are defined in the settings tab.", "Error"); tabControl1.SelectedIndex = 1; return; } if (txtb_xbox_jsrf_dir.Text == "") { MessageBox.Show("Please set the xbox JSRF folder in the xbox FTP Settings.", "Error"); tabControl1.SelectedIndex = 1; return; } string filepath = get_selected_graffiti_filepath(); string filepath_noExt = filepath.Replace(".tga", ""); // check if graffiti file path is valid and if file exists if (filepath == "") { return; } if (!File.Exists(filepath_noExt + ".grf")) { MessageBox.Show("Could not find file: \n" + filepath_noExt + ".grf", "Error: missing file"); return; } if (!File.Exists(filepath_noExt + ".prs")) { MessageBox.Show("Could not find file: \n" + filepath_noExt + ".prs", "Error: missing file"); return; } // test ping xbox if (!PingHost(txtb_xbox_debug_ip.Text)) { MessageBox.Show("Could not ping the Xbox, make sure the xbox is running on the dashboard \nwith FTP and that the FTP settings are correct.", "Error"); tabControl1.SelectedIndex = 1; return; } // check if ftp connects // create ftp client with xbox login/password defined in Settings tab ftp ftpClient = new ftp(@"ftp://" + txtb_xbox_debug_ip.Text + "/", txtb_xbox_login.Text, txtb_xbox_pass.Text); string subFolfder = ""; int split_dir_at = 0; string[] folders = filepath.Split(Path.DirectorySeparatorChar); // find the "Media" folder in path and substract the parent folders from it for (int i = 0; i < folders.Length; i++) { if (folders[i] == "TEX") { split_dir_at = i; } } for (int i = split_dir_at + 1; i < folders.Length; i++) { subFolfder = subFolfder + "\\" + folders[i]; } ftpClient.upload((txtb_xbox_jsrf_dir.Text + "Mark/TEX/" + Path.GetFileNameWithoutExtension(filepath) + ".grf").Replace("\\", "/"), @filepath_noExt + ".grf"); ftpClient.upload((txtb_xbox_jsrf_dir.Text + "Mark/TEX/" + Path.GetFileNameWithoutExtension(filepath) + ".prs").Replace("\\", "/"), @filepath_noExt + ".prs"); // delete file from cache (so the game will reload the new modded file we just uploaded) ftpClient.delete("X:/Media/Mark/TEX/"); ftpClient.delete("Y:/Media/Mark/TEX/"); ftpClient.delete("Z:/Media/Mark/TEX/"); System.Media.SystemSounds.Beep.Play(); }
public void delete(string str) { ftp ftpClient = new ftp(@"ftp://39.104.81.205/", "ftpuser", "ftpuser"); ftpClient.delete(str); }