Skip to content

Class FTPHelper ​

Namespace: Tool.Utils.FtpHelper
Assembly: Tool.Net.dll

FTP帮助类(推荐使用:FluentFTP)

csharp
[Obsolete("FTP 过时 是因为 6.0 版本 将WebRequest 设置为了过时,目前还可用,后期可能取消 或 改用其他方式。")]
public class FTPHelper

Inheritance ​

object ← FTPHelper

Inherited Members ​

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Extension Methods ​

ObjectExtension.Add<T>(object, object, object), ObjectExtension.CopyEntity(object, object, params string[]), ObjectExtension.EntityToJson(object), ObjectExtension.EntityToJson(object, bool), ObjectExtension.EntityToJson(object, bool, string), DictionaryExtension.GetDictionary(object), TypeExtension.GetFieldKey(object, string, out bool), TypeExtension.GetFieldKey<T>(object, string, out bool), TypeExtension.GetFieldKey(object, Type, string, out bool), ObjectExtension.GetIntPtr(object), ObjectExtension.GetIntPtrInt(object), TypeExtension.GetPropertieFind(object, string, bool), TypeExtension.GetProperties(object), TypeExtension.GetPropertyKey(object, string, out bool), TypeExtension.GetPropertyKey<T>(object, string, out bool), TypeExtension.GetPropertyKey(object, Type, string, out bool), TypeExtension.GetValue(object, PropertyDescriptor), TypeExtension.GetValue(object, string, bool), TypeExtension.GetValue(object, string), ObjectExtension.Read<T>(object, object, int, int), ObjectExtension.Read<T>(object, int, object, int, int), DictionaryExtension.SetDictionary(object, IDictionary<string, object>), TypeExtension.SetFieldKey(object, string, object), TypeExtension.SetFieldKey<T>(object, string, object), TypeExtension.SetFieldKey(object, Type, string, object), TypeExtension.SetPropertyKey(object, string, object), TypeExtension.SetPropertyKey<T>(object, string, object), TypeExtension.SetPropertyKey(object, Type, string, object), TypeExtension.SetValue(object, PropertyDescriptor, object), TypeExtension.SetValue(object, string, object, bool), TypeExtension.SetValue(object, string, object), ObjectExtension.ToBase64String(object), ObjectExtension.ToBytes(object), ObjectExtension.ToBytes(object, out Type), DictionaryExtension.ToDictionary(object), DictionaryExtension.ToDictionary<T>(object), DictionaryExtension.ToIDictionary(object), DictionaryExtension.ToIDictionary<T>(object), ObjectExtension.ToJson(object), ObjectExtension.ToJson(object, JsonSerializerOptions), ObjectExtension.ToJsonWeb(object), ObjectExtension.ToJsonWeb(object, Action<JsonSerializerOptions>), ObjectExtension.ToTryVar<T>(object, T), ObjectExtension.ToVar<T>(object), ObjectExtension.ToVar(object, Type, bool), ObjectExtension.ToVar(object, string), ObjectExtension.ToXml(object)

Constructors ​

FTPHelper(string, string, string, string) ​

连接FTP服务器

csharp
public FTPHelper(string FtpServerIP, string FtpRemotePath, string FtpUserID, string FtpPassword)

Parameters ​

FtpServerIP string

FTP连接地址

FtpRemotePath string

指定FTP连接成功后的当前目录, 如果不指定即默认为根目录

FtpUserID string

用户名

FtpPassword string

密码

Methods ​

Delete(string) ​

删除文件

csharp
public void Delete(string fileName)

Parameters ​

fileName string

Download(string, string) ​

下载

csharp
public void Download(string filePath, string fileName)

Parameters ​

filePath string

fileName string

FileExist(string) ​

判断当前目录下指定的文件是否存在

csharp
public bool FileExist(string RemoteFileName)

Parameters ​

RemoteFileName string

远程文件名

Returns ​

bool

GetAllList(string) ​

获取FTP文件列表(包括文件夹)

csharp
public string[] GetAllList(string url)

Parameters ​

url string

请求地址

Returns ​

string[]

GetFileList(string) ​

获取当前目录下文件列表(不包括文件夹)

csharp
public string[] GetFileList(string url)

Parameters ​

url string

Returns ​

string[]

GetFileSize(string) ​

获取指定文件大小

csharp
public long GetFileSize(string filename)

Parameters ​

filename string

Returns ​

long

GetFilesDetailList() ​

获取当前目录下明细(包含文件和文件夹)

csharp
public string[] GetFilesDetailList()

Returns ​

string[]

GotoDirectory(string, bool) ​

切换当前目录

csharp
public void GotoDirectory(string DirectoryName, bool IsRoot)

Parameters ​

DirectoryName string

目录地址

IsRoot bool

true:绝对路径 false:相对路径

MakeDir(string) ​

创建文件夹

csharp
public void MakeDir(string dirName)

Parameters ​

dirName string

MovieFile(string, string) ​

移动文件

csharp
public void MovieFile(string currentFilename, string newDirectory)

Parameters ​

currentFilename string

newDirectory string

ReName(string, string) ​

更改文件名

csharp
public void ReName(string currentFilename, string newFilename)

Parameters ​

currentFilename string

newFilename string

Upload(string) ​

上传

csharp
public void Upload(string filename)

Parameters ​

filename string

基于Apache-2.0协议开源