public void FtpTest() { string errorinfo; Common.FtpHelper ftp = new Common.FtpHelper(); ftp.FtpUpDown("192.168.240.63", "vsftp", "/.,qwe123"); ftp.MakeDir("/upimg/201308/"); bool flag = ftp.Upload("E:\\test\\/upimg/201308/09133937235.jpg", "/upimg/201308/231.jpg", out errorinfo); }
/// <summary> /// 导出到SCV文件 /// </summary> /// <param name="FileName"></param> public Boolean ToCsv(String FileName, Boolean UpFtp) { if (FileName.Trim() == String.Empty && this.NowData.Count == 0) { return(false); } String SentPath = FileName + "/Gy_Send_Temp/"; if (!Directory.Exists(SentPath)) { Directory.CreateDirectory(SentPath); } String NowNo = GetNo(SentPath); String SaveFileName = SentPath + "Dv_" + DateTime.Now.ToString("yyyyMMdd") + "_" + ClientNo + "_" + NowNo + ".Csv"; Boolean State = this.DataToCsv(SaveFileName); if (State && UpFtp) { String SentBackPath = FileName + "/Gy_Send_Back/"; if (!Directory.Exists(SentBackPath)) { Directory.CreateDirectory(SentBackPath); } DirectoryInfo Dr = new DirectoryInfo(SentPath); var Files = Dr.GetFiles().ToList(); if (Files.Count(x => !x.Name.ToLower().Equals(Path.GetFileName(SaveFileName.ToLower()))) > 0) { Common.FtpHelper Ftp = new Common.FtpHelper(new Uri(Address), Uid, Pwd); Ftp.DirectoryPath = @"/upload/"; foreach (var a in Files.Where(x => !x.Name.ToLower().Equals(Path.GetFileName(SaveFileName.ToLower())))) { if (Ftp.UploadFile(a.FullName)) { File.Move(a.FullName, SentBackPath + Path.GetFileName(a.FullName)); } } } } return(State); }
public void GyFtp(DataTable dt, string ftpPaht) { Common.CsvHelp.writeCsv(dt, ftpPaht); Common.FtpHelper gyFtp = new Common.FtpHelper(new Uri("Ftp://www.ubg.com.tw"), "Dv36g52", "y6^G55kA"); gyFtp.UploadFile(ftpPaht); }