网站导航网学 原创论文 原创专题 网站设计 最新系统 原创论文 论文降重 发表论文 论文发表 UI设计定制 论文答辩PPT格式排版 期刊发表 论文专题
返回网学首页
网学原创论文
最新论文 推荐专题 热门论文 论文专题
当前位置: 网学 > 交易代码 > ASP.Net精品代码 > 正文

ftp操作实现类

论文降重修改服务、格式排版等 获取论文 论文降重及排版 论文发表 相关服务

  Imports System

  Imports System.Net

  Imports System.IO

  Imports System.Text

  Imports System.Net.Sockets

  Public Class CMyFTP

  #Region "Class Variable Declarations"

  Private m_sRemoteHost, m_sRemotePath, m_sRemoteUser As String

  Private m_sRemotePassword, m_sMess As String

  Private m_iRemotePort, m_iBytes As Int32

  Private m_objClientSocket As Socket

  Private m_iRetValue As Int32

  Public m_bLoggedIn As Boolean

  Private m_sMes, m_sReply As String

  'Set the size of the packet that is used to read and to write data to the FTP server

  'to the following specified size.

  Public Const BLOCK_SIZE = 512

  Private m_aBuffer(BLOCK_SIZE) As Byte

  Private ASCII As Encoding = Encoding.ASCII

  Public flag_bool As Boolean

  'General variable declaration

  Private m_sMessageString As String

  #End Region

  #Region "Class Constructors"

  '创建ftp对象

  Public Sub New()

  m_sRemoteHost = "127.0.0.1"

  m_sRemotePath = "."

  m_sRemoteUser = "ftpuser"

  m_sRemotePassword = "ftppass"

  m_sMessageString = ""

  m_iRemotePort = 21

  m_bLoggedIn = False

  End Sub

  ' Parameterized constructor

  Public Sub New(ByVal sRemoteHost As String, _

  ByVal sRemotePath As String, _

  ByVal sRemoteUser As String, _

  ByVal sRemotePassword As String, _

  ByVal iRemotePort As Int32)

  m_sRemoteHost = sRemoteHost

  m_sRemotePath = sRemotePath

  m_sRemoteUser = sRemoteUser

  m_sRemotePassword = sRemotePassword

  m_sMessageString = ""

  m_iRemotePort = 21

  m_bLoggedIn = False

  End Sub

  #End Region

  #Region "FTP连接相关设置 "

  'Set or Get the name of the FTP server that you want to connect.

  Public Property RemoteHostFTPServer() As String

  'Get the name of the FTP server.

  Get

  Return m_sRemoteHost

  End Get

  'Set the name of the FTP server.

  Set(ByVal Value As String)

  m_sRemoteHost = Value

  End Set

  End Property

  'Set or Get the FTP Port Number of the FTP server that you want to connect.

  Public Property RemotePort() As Int32

  'Get the FTP Port Number.

  Get

  Return m_iRemotePort

  End Get

  'Set the FTP Port Number.

  Set(ByVal Value As Int32)

  m_iRemotePort = Value

  End Set

  End Property

  'Set or Get the remote path of the FTP server that you want to connect.

  Public Property RemotePath() As String

  'Get the remote path.

  Get

  Return m_sRemotePath

  End Get

  'Set the remote path.

  Set(ByVal Value As String)

  m_sRemotePath = Value

  End Set

  End Property

  'Set or Get the remote password of the FTP server that you want to connect.

  Public Property RemotePassword() As String

  Get

  Return m_sRemotePassword

  End Get

  Set(ByVal Value As String)

  m_sRemotePassword = Value

  End Set

  End Property

  'Set or Get the remote user of the FTP server that you want to connect.

  Public Property RemoteUser() As String

  Get

  Return m_sRemoteUser

  End Get

  Set(ByVal Value As String)

  m_sRemoteUser = Value

  End Set

  End Property

  'Set the class MessageString.

  Public Property MessageString() As String

  Get

  Return m_sMessageString

  End Get

  Set(ByVal Value As String)

  m_sMessageString = Value

  End Set

  End Property

  #End Region

  #Region "Public Subs and Functions"

  #Region "获取FTP服务器中指定目录的所有文件名"

  'Return a list of files in a string() array from the file system.

  Public Function GetFileList(ByVal sMask As String) As String()

  Dim cSocket As Socket

  Dim bytes As Int32

  Dim seperator As Char = ControlChars.Lf

  Dim mess() As String

  Dim i As Integer = 0

  m_sMes = ""

  'Check if you are logged on to the FTP server.

  

  • 下一篇资讯: 数据库操作通类实现
  • 设为首页 | 加入收藏 | 网学首页 | 原创论文 | 计算机原创
    版权所有 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
    Copyright 2008-2020 myeducs.Cn www.myeducs.Cn All Rights Reserved 湘ICP备09003080号 常年法律顾问:王律师