91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

C# FTP操作幫助類, FTPHelper.cs,已經(jīng)封裝好了FTP相關(guān)的各個操作的方法

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.Text;
using?System.IO;
using?System.Net;
using?System.Text.Regularexpressions;

namespace?libDbHelper
{
????///???
????///?FTP幫助類??
????///?
??
????public?class?FTPHelper
????{
????????#region?字段
????????string?ftpURI;
????????string?ftpUserID;
????????string?ftpServerIP;
????????string?ftpPassword;
????????string?ftpRemotePath;
????????#endregion

????????#region?連接FTP服務(wù)器
????????///?????
????????///?連接FTP服務(wù)器??
????????///?
????
????????///?FTP連接地址????
????????///?指定FTP連接成功后的當前目錄?如果不指定即默認為根目錄????
????????///?用戶名????
????????///?密碼????
????????public?FTPHelper(string?FtpServerIP?string?FtpRemotePath?string?FtpUserID?string?FtpPassword)
????????{
????????????ftpServerIP?=?FtpServerIP;
????????????ftpRemotePath?=?FtpRemotePath;
????????????ftpUserID?=?FtpUserID;
????????????ftpPassword?=?FtpPassword;
????????????ftpURI?=?“ftp://“?+?ftpServerIP?+?“/“?+?ftpRemotePath?+?“/“;
????????}
????????#endregion

????????#region?上傳
????????///?????
????????///?上傳????
????????///?
?????
????????public?bool?Upload(string?filename)
????????{
????????????try
????????????{
????????????????FileInfo?fileInf?=?new?FileInfo(filename);
????????????????FtpWebRequest?reqFTP;
????????????????reqFTP?=?(FtpWebRequest)FtpWebRequest.Create(new?Uri(ftpURI?+?fileInf.Name));
????????????????reqFTP.Credentials?=?new?NetworkCredential(ftpUserID?ftpPassword);
????????????????reqFTP.Method?=?WebRequestMethods.Ftp.UploadFile;
????????????????reqFTP.KeepAlive?=?false;
????????????????reqFTP.UseBinary?=?true;
????????????????reqFTP.ContentLength?=?fileInf.Length;
????????????????int?buffLength?=?2048;
????????????????byte[]?buff?=?new?byte[buffLength];
????????????????int?contentLen;
????????????????FileStream?fs?=?fileInf.OpenRead();
????????????????try
????????????????{
????????????????????Stream?strm?=?reqFTP.GetRequestStream();
????????????????????contentLen?=?fs.Read(buff?0?buffLength);
????????????????????while?(contentLen?!=?0)
????????????????????{
????????????????????????strm.Write(buff?0?contentLen);
????????????????????????contentLen?=?fs.Read(buff?0?buffLength);
????????????????????}
????????????????????strm.Close();
????????????????????fs.Close();
????????????????}
????????????????catch?(Exception?ex)
????????????????{
????????????????????throw?new?Exception(ex.Message);
????????????????}
????????????????return?true;
????????????}
????????????catch
????????????{
????????????????return?false;
????????????}
????????}
????????#endregion

????????#region?下載
????????///?????
????????///?下載????
????????///?
?????
????????public?bool?Download(string?filePath?string?fileName)
????????{
????????????try
????????????{

評論

共有 條評論