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 button1_Click(object sender, EventArgs e) { ftp ftpClient = new ftp(@"ftp://waws-prod-sg1-001.ftp.azurewebsites.windows.net", @"MBDevAsiaAPI2\RSMahesh", "1234test!"); /* Upload a File */ ftpClient.upload("", @"C:\test.txt"); }
public void WriteToFTP(string ftpPath, string localFilePath) { // ftp ftpClient = new ftp("ftp://en1372.mirohost.net/", "Math4Ami", "dXf8E7nl01dGLz"); ftp ftpClient = new ftp("ftp://en1372.mirohost.net/", "Math2AmiTest", "Glj946ra2Hqm"); ftpClient.upload(ftpPath, localFilePath); }
// EXAMPLE // /* Create Object Instance */ // ftp ftpClient = new ftp("ftp://10.10.10.10/", "user", "password"); // // /* 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; public void ReadFromFTP(string ftpPathToFile, string localPathToSave) { // ftp ftpClient = new ftp("ftp://en1372.mirohost.net/", "Math4Ami", "dXf8E7nl01dGLz"); ftp ftpClient = new ftp("ftp://en1372.mirohost.net/", "Math2AmiTest", "Glj946ra2Hqm"); ftpClient.download(ftpPathToFile, localPathToSave); }
private void carga_FTP(string interfaces) { // string fecha = Convert.ToString(dateTimePicker1.Value.ToString("ddMMyyyy")); string user = USER; string pass = SFTPKEY; // string direccion = "ftp://190.143.71.122/Inbox/"; string direccion = HOST + "/Inbox"; ftp ftpClient = new ftp(HOST + ":" + PUERTO, user, pass); FtpWebRequest arh = (FtpWebRequest)FtpWebRequest.Create(new Uri(direccion + interfaces)); arh.Method = WebRequestMethods.Ftp.UploadFile; arh.Proxy = null; arh.Credentials = new NetworkCredential(user, pass); arh.UsePassive = true; arh.KeepAlive = true; FileStream fs = File.OpenRead(Carpeta_local); byte[] buffer = new byte[fs.Length]; fs.Read(buffer, 0, buffer.Length); fs.Close(); Stream ftpstream = arh.GetRequestStream(); ftpstream.Write(buffer, 0, buffer.Length); ftpstream.Close(); }
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; }
IEnumerator UploadFileAsync(string filename, bool demo = false) { try { ftp ftpClient; if (demo) { ftpClient = new ftp("ftp://xo2.x10hosting.com/public_html/DemoVersion/", "dioramaw", "1qaz@WSX3edc$RFV"); } else { ftpClient = new ftp("ftp://xo2.x10hosting.com/public_html/Uploads/", "dioramaw", "1qaz@WSX3edc$RFV"); } if (uploadName == "") { uploadName = DateTime.Now.ToUniversalTime().ToString("yyyyMMddhhmmss_") + Path.GetRandomFileName() + ".dio"; } ftpClient.upload(uploadName, filename); ftpClient = null; } catch { Debug.Log("Failed"); } yield break; }
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); } } }
private void viewRemoteListView(FtpInfo info, ftp ftpClient, string remotePath) { string[] dirInfo = ftpClient.directoryListDetailed(remotePath); string dir_name = string.Empty; string dir_option = string.Empty; string Temp = string.Empty; txt_remothPath.Text = remotePath; if (listBox_Remote.Items.Count > 0) { listBox_Remote.Items.Clear(); } listBox_Remote.Items.Add(".."); foreach (string dir in dirInfo) { if (dir.Length > 1) { //dir -> "drwxr-xr-x 1 ftp ftp 0 Sep 07 17:04 folder1" dir_name = dir.Substring(dir.LastIndexOf(':') + 4); dir_option = dir.Substring(0, dir.IndexOf(' ')); if (dir_name.IndexOf('/') > 0) { Temp = dir_name.Substring(dir.LastIndexOf('/') + 1); listBox_Remote.Items.Add(Temp); } else { listBox_Remote.Items.Add(dir_name); } } } }
public void DownloadFileFromUploads(string filename) { ftp ftpClient = new ftp("ftp://xo2.x10hosting.com/public_html/Uploads/", "dioramaw", "1qaz@WSX3edc$RFV"); ftpClient.download(filename, Globals.TEMPFOLDER + filename); ftpClient = null; }
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); } } }
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 timedSending(object Sender, EventArgs e) { logs += "Sending Files......."; label10.Visible = true; textBox8.Text += logs + Environment.NewLine; saveLog(logs); logs = ""; var uri = new Uri("ftp://" + confList["Server"]); /* Create Object Instance */ ftp ftpClient = new ftp(uri.ToString(), confList["Username"], confList["Password"]); string newFolder = confList["Fpath"] + "/" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss"); if (radioButton3.Checked) { newFolder = newFolder + "_" + textBox13.Text + "_UPPER"; } else { newFolder = newFolder + "_" + textBox13.Text + "_LOWER"; } System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; ftpClient.createDirectory(newFolder); recursiveDirectory(textBox4.Text, newFolder, ftpClient); System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default; updateTreeView(); label10.Visible = false; }
static void Main(string[] args) { try { if (global.config.exist()) { global.config config = new global.config(); sharedOP.WriteToLog("Inicio de FTPTools:" + global.config.descripcion, "Tarea iniciada con exito"); ftp oFtp = new ftp(global.config.sftp, global.config.user, global.config.pass, global.config.proxy_user, global.config.proxy_pass, global.config.useproxy); Console.WriteLine("/**********FTPTOOLS*************/"); Console.WriteLine("Fichero:" + global.config.fichero); Console.WriteLine("Ftp:" + global.config.sftp); if (global.config.action == "download") { Console.WriteLine("Accion:" + global.config.action); oFtp.download(global.config.fichero, global.config.rutLocal + "/" + global.config.fichero); sharedOP.WriteToLog("Download", "Descarga de " + global.config.fichero + " realizada correctamente"); } if (global.config.action == "upload") { Console.WriteLine("Accion:" + global.config.action); oFtp.upload(global.config.fichero, global.config.rutLocal + "/" + global.config.fichero); sharedOP.WriteToLog("Upload", "Subida de " + global.config.fichero + " realizada correctamente"); } } else { global.Errores.add(new Exception("No se encuentra el fichero de configuración")); } } catch (Exception ex) { Console.WriteLine("/**********ERRORES*************/"); Console.WriteLine("Error: " + ex.Message.ToString()); Console.WriteLine("StackTrace: " + ex.StackTrace); global.Errores.add(ex); } if (global.Errores.getNuErrores() >= 1) { global.Errores.writeLog(); //global.Errores.sendEmail(); //Envio por ASPMail que va bastante mejor que la caca de microsoft if (global.config.emailTipo == "EmailAgent") { global.Errores.sendEmailAgent(); } else if (global.config.emailTipo == "SmtpFramework") { global.Errores.sendEmail(); } else { global.Errores.sendEmail(); } } }
private void timer3_Tick(object sender, EventArgs e) { List <DateClass> dateList = new List <DateClass>(); var uri = new Uri("ftp://" + confList["Server"]); /* Create Object Instance */ ftp ftpClient = new ftp(uri.ToString(), confList["Username"], confList["Password"]); var dirStr = ftpClient.directoryListDetailed(confList["Fpath"]); if (dirStr.Count() > 3) { foreach (var item in dirStr) { if (item != "") { var cdate = creationDate(item); dateList.Add(cdate); } } dateList.Sort(delegate(DateClass x, DateClass y) { return(y.FullDate.CompareTo(x.FullDate)); }); //Using WinSCP for deleting directories string bareServer = confList["Server"].Split(':')[0]; SessionOptions sessionOptions = new SessionOptions { Protocol = Protocol.Ftp, HostName = bareServer, UserName = confList["Username"], Password = confList["Password"], }; sessionOptions.AddRawSettings("ProxyPort", "0"); int sizeKeep = 1; sizeKeep = Convert.ToInt32(confList["Keep"]); for (int i = sizeKeep; i < dateList.Count; i++) { using (Session session = new Session()) { // Connect session.Open(sessionOptions); // Delete folder session.RemoveFiles(confList["Fpath"] + "/" + dateList[i].Name).Check(); } logs += "Directory:--" + dateList[i].Name + "-- was removed" + Environment.NewLine; saveLog(logs); textBox8.Text += logs; logs = ""; } updateTreeView(); } }
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"); }
public void DownloadRandomFile() { ftp ftpClient = new ftp("ftp://xo2.x10hosting.com/public_html/Uploads/", "dioramaw", "1qaz@WSX3edc$RFV"); string[] simpleDirectoryListing = ftpClient.directoryListSimple("/"); //UpdateLog("Number of uploaded Dioramas: " + (simpleDirectoryListing.Length - 2)); int i = UnityEngine.Random.Range(2, simpleDirectoryListing.Length - 1); ftpClient.download(simpleDirectoryListing[i], Globals.TEMPFOLDER + "temp.dio"); ftpClient = null; }
//접속 버튼 private void btn_Connect_Click(object sender, EventArgs e) { //Debug txt_Host.Text = @"localhost"; txt_Id.Text = @"test"; txt_Password.Text = @"test"; //FTP Config FtpInfo info = ReadFtpConfig(); ftp ftpClient = new ftp(string.Format(@"ftp://{0}/{1}", info.host, info.remotePath), info.id, info.password); //Remote Directory List viewRemoteListView(info, ftpClient, "/"); }
public void PostTOserver() { string imgPath = Application.persistentDataPath + "/Initial/Default.png"; ftp ftpClient = new ftp(@"ftp://192.168.0.101/", "sling", "socialiot1212"); Debug.Log("Image Path: " + imgPath); ftpClient.upload("Default.png", @imgPath); Debug.Log(ftpClient); /* Get the Size of a File */ string fileSize = ftpClient.getFileSize("Default.png"); Debug.Log(fileSize); }
private void upload(string table, string name, string surffix, string localFile) { ftp ftpClient = new ftp(@"ftp://39.104.81.205/", "ftpuser", "ftpuser"); string ImageDirectory = Root + "/" + table + "/" + "Images/"; //ftpClient.createDirectory(ImageDirectory); /* Upload a File */ string remoteFile = ImageDirectory + name + surffix; Debug.Log(remoteFile); Debug.Log(localFile); ftpClient.upload(remoteFile, localFile); }
private void button_connect_Click(object sender, EventArgs e) { string adres = textBox_adres.Text + ":" + textBox_port.Text + textBox_folder.Text; string login = textBox_login.Text; string haslo = textBox_password.Text; ftp ftpClient = new ftp(adres, login, haslo); string[] detailDirectoryListing = ftpClient.directoryListDetailed(); for (int i = 0; i < detailDirectoryListing.Count(); i++) { textBox_log.AppendText(detailDirectoryListing[i]); textBox_log.AppendText("\r\n"); } ftpClient = null; }
//다운로드 버튼 ( '>' ) private void btn_Download_Click(object sender, EventArgs e) { string fileName = string.Empty; string localFullPath = string.Empty; FtpInfo info = ReadFtpConfig(); ftp ftpClient = new ftp(string.Format(@"ftp://{0}/{1}", info.host, info.remotePath), info.id, info.password); fileName = listBox_Remote.SelectedItem.ToString(); info.lFiles.Add(fileName); localFullPath = string.Format(@"{0}{1}", txt_localpath.Text, fileName); ftpClient.download(fileName, localFullPath); //Local Directory List viewLocalListView(txt_localpath.Text); }
void ProcessParallelThread() { var Files = rProcess.GetFileToFolder(rProcess.tmpFolder, "pdf"); foreach (var xFile in Files) { try { var ftp = new ftp(@"ftp://188.121.43.20/services.danubeco.com/", "ranking"); // Upload PDF using FTP to Server Folder -> supplierx var result = ftp.Upload(Path.Combine("ranking", xFile.Name), Path.Combine(new RANKProcess().tmpFolder, xFile.Name)); if (result.Success) { var reqIDD = Path.GetFileNameWithoutExtension(xFile.Name); var newObj = db.reqlists.FirstOrDefault(s => s.reqid.Equals(reqIDD)); if (newObj.sts.Equals("processing")) { newObj.sts = "processed"; newObj.lnk = xFile.Name; db.SaveChanges(); } rProcess.moveToBckFolder(xFile); updateLog(xFile, "Success", Color.Green); } else { rProcess.moveToErrFolder(xFile); updateLog(xFile, "ErrorFTP", Color.Red); } } catch (Exception ex) { rProcess.moveToErrFolder(xFile); updateLog(xFile, "ErrorFile : " + ex.Message, Color.Red); } } }
IEnumerator SaveToBest(string filename) { try { ftp ftpClient; ftpClient = new ftp("ftp://xo2.x10hosting.com/public_html/Best/", "dioramaw", "1qaz@WSX3edc$RFV"); uploadName = DateTime.Now.ToUniversalTime().ToString("yyyyMMddhhmmss_") + Path.GetRandomFileName() + ".dio"; ftpClient.upload(uploadName, filename); ftpClient = null; } catch { Debug.Log("Failed"); } yield break; }
//업로드 버튼 ( '<' ) private void btn_upload_Click(object sender, EventArgs e) { string fileName = string.Empty; string localFullPath = string.Empty; string remoteFullPath = string.Empty; FtpInfo info = ReadFtpConfig(); ftp ftpClient = new ftp(string.Format(@"ftp://{0}/{1}", info.host, info.remotePath), info.id, info.password); fileName = listBox_Local.SelectedItem.ToString(); info.lFiles.Add(fileName); localFullPath = string.Format(@"{0}{1}", txt_localpath.Text, fileName); remoteFullPath = string.Format(@"{0}/{1}", txt_remothPath.Text, fileName); ftpClient.upload(remoteFullPath, localFullPath, true, true); //Remote Directory List viewRemoteListView(info, ftpClient, txt_remothPath.Text); }
private IEnumerator initialize() { ftp ftpClient = new ftp(Accessories.FTP_ADDRESS(key), Accessories.FTP_USERNAME(key), Accessories.FTP_PASSWORD(key)); if (Directory.Exists(LOCAL_DATA_ROOT_PATH) == false) //If the data folder doesn't exist { Directory.CreateDirectory(LOCAL_DATA_ROOT_PATH); //Create it } if (File.Exists(LOCAL_DATA_ROOT_PATH + REGISTERED_USERS_FILE_PATH)) //If the registered users file is still there { File.Delete(LOCAL_DATA_ROOT_PATH + REGISTERED_USERS_FILE_PATH); //Remove it } //Download the files CoroutineWithData cd = new CoroutineWithData(this, ftpClient.downloadAsync(WEB_DATA_ROOT_PATH + REGISTERED_USERS_FILE_PATH, LOCAL_DATA_ROOT_PATH + REGISTERED_USERS_FILE_PATH)); yield return(cd.coroutine); //Once everything has been downloaded (or not) if (cd.result.ToString().Equals(ftp.sucessMessage)) //If the ftp file download succeeded { SplitRegisteredUserFile(); //Attempt to CheckForCurrentCredentials(); MultiSceneVariables.Instance.Online = true; LoginCanvasManager.current.EnableCanvas(); //Disable the canvas //OfflineCanvasManager.current.DisableCanvas(); //Enable the offline option } else if (cd.result.ToString().Equals(ftp.failMessage)) //If the ftp file download failed { print("Running fail"); NotificationManager.Instance.ShowNotification(NotificationType.TOP, "Unable to Connect to server", Mathf.Infinity, Color.red); MultiSceneVariables.Instance.Online = false; LoginCanvasManager.current.DisableCanvas(); //Disable the canvas //OfflineCanvasManager.current.EnableCanvas(); //Enable the offline option } }
public List <string> GetAllFiles() { List <string> files = new List <string>(); ftp ftpClient = new ftp("ftp://xo2.x10hosting.com/public_html/Uploads/", "dioramaw", "1qaz@WSX3edc$RFV"); /* Get Contents of a Directory (Names Only) */ string[] simpleDirectoryListing = ftpClient.directoryListSimple("/"); for (int i = 0; i < simpleDirectoryListing.Count(); i++) { if (simpleDirectoryListing[i].LastIndexOf(".dio") > 0) { files.Add(simpleDirectoryListing[i]); } } ftpClient = null; files = files.OrderByDescending(q => q).ToList(); return(files); }
//Remote 더블클릭 이벤트 (경로 이동) private void listBox_Remote_DoubleClick(object sender, EventArgs e) { string localPath = string.Empty; string[] temp = txt_remothPath.Text.Split('/'); FtpInfo info = ReadFtpConfig(); ftp ftpClient = new ftp(string.Format(@"ftp://{0}/{1}", info.host, info.remotePath), info.id, info.password); if (listBox_Remote.SelectedIndex == 0 && temp.Count() > 1 && temp[1] != string.Empty) { for (int i = 0; i < temp.Count() - 1; i++) { if (temp[i] != string.Empty) { if (info.remotePath == "/") { info.remotePath += string.Format(@"{0}", temp[i]); } else { info.remotePath += string.Format(@"/{0}", temp[i]); } } } viewRemoteListView(info, ftpClient, info.remotePath); } else if (listBox_Remote.SelectedIndex > 0) { if (txt_remothPath.Text == "/") { info.remotePath = string.Format(@"{0}{1}", txt_remothPath.Text, listBox_Remote.SelectedItem); } else { info.remotePath = string.Format(@"{0}/{1}", txt_remothPath.Text, listBox_Remote.SelectedItem); } viewRemoteListView(info, ftpClient, info.remotePath); } }
/// <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; } }
private void btnDownload_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; ftp ftpClientLocal = new ftp(StaticVarClass.ftp_Server, StaticVarClass.ftp_Username, StaticVarClass.ftp_Password); if (ftpClientLocal.download(str_EmployeeGlobal, ftpInfo.FileName, ftpInfo.FullName)) { // Load lại attachFile. this.loadDataAttachFile(); // Làm sạch control. this.clearDownload(); this.disableAttachFileDownload(true); XtraMessageBox.Show("Successfully downloaded!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { XtraMessageBox.Show("Download failed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void UIButton_Download(){ ftp ftpClient = new ftp(@"ftp://140.131.152.3:7223/FTP/momoya", "momo6699", "123"); //ftp ftpClient = new ftp(@"ftp://140.131.152.5:7223/Volume_1/momoya/", "momo6699", "123456"); // 參數: (ftp端 要存的檔案名稱, 本地端的路徑 note: 副檔名非常重要 jpg jpeg png 要分清楚) string str1 = usernameandpic[0] + ".png"; string str2 = "/sdcard/" + usernameandpic[0] + ".png"; //ftpClient.download(@"AR_test.jpg" , @str2); ftpClient.download(@str1 , @str2); DataManger.new_pic_path = img_path_prefix + str2; DataManger.b = true; checksent(); }
public void PiconClick(){ //取得目前時間 pic_name = DateTime.Now.ToShortTimeString(); //螢幕擷取 Application.CaptureScreenshot(pic_name+".png"); String pic_path = path + pic_name + ".png"; try{ //此為暫存器,儲存上傳次數+使用者姓名 string str = piccount + nickName ; ftp ftpClient = new ftp(@"ftp://140.131.152.3:7223/FTP/momoya", "momo6699", "123"); //ftp ftpClient = new ftp(@"ftp://140.131.152.5:7223/Volume_1/momoya/", "momo6699", "123456"); // 參數: (ftp端 要存的檔案名稱, 本地端的路徑 note: 副檔名非常重要 jpg jpeg png 要分清楚) ftpClient.upload( str + ".png" , @pic_path); //修改刪除線0627加入指定圖片分享 //------------------------------------------------------------------------------------ //檢查藍色小人是否被點選 CheckMan(); //傳送圖片訊息*使用者姓名*上傳的檔名 SendMessage(sentpic + "*" + nickName + "*" + str); //傳送次數+1,藉此變更傳送圖片 piccount++; //------------------------------------------------------------------------------------ }catch(Exception e){ SendMessage("Client " + e.ToString()); } }
private ftp connectFTP() { try { string host = Util.Decrypt(INI.ReadValue("FTP", "host")); string user = Util.Decrypt(INI.ReadValue("FTP", "user")); string password = Util.Decrypt(INI.ReadValue("FTP", "password")); ftp ftp = new ftp(host, user, password); return ftp; } catch (Exception ex) { throw new Exception(ex.Message, ex.InnerException); } }
public FtpUpload(string remote, string user, string password, string remoteFolder, string localFolder) { ftpClient = new ftp(remote, user, password); this.remoteFolder = remoteFolder; this.localFolder = localFolder; }