高手能帮我给这两段代码加上注释么?
从FTP上下载文件:
Public Sub DownloadFile(ByVal Str_RemoteFileName As String, ByVal Str_LocalFileName As String, ByVal Bool_Resume As Boolean)
Dim Data_St As Stream
Dim output As FileStream
Dim LobSocket As Socket
Dim offset, npos As Long
If (Not Logined()) Then
Logined()
End If
SetBinaryMode(True)
If (Str_LocalFileName.Equals("")) Then
Str_LocalFileName = Str_RemoteFileName
End If
If (Not (File.Exists(Str_LocalFileName))) Then
Data_St = File.Create(Str_LocalFileName)
Data_St.Close()
End If
output = New FileStream(Str_LocalFileName, FileMode.Open)
LobSocket = CreateDataSocket()
offset = 0
If (Bool_Resume) Then
offset = output.Length
If (offset > 0) Then
SendCommand("REST " & offset)
Str_Reply = ServerReply(True)
Int_Reply = Int32.Parse(Str_Reply.Substring(0, 3))
If (Int_Reply <> 350) Then
offset = 0
End If
End If
If (offset > 0) Then
npos = output.Seek(offset, SeekOrigin.Begin)
End If
End If
SendCommand("RETR " & Str_RemoteFileName)
Str_Reply = ServerReply(True)
Int_Reply = Int32.Parse(Str_Reply.Substring(0, 3))
If (Not (Int_Reply = 150 Or Int_Reply = 125)) Then
MsgBox(Str_Reply.Substring(4))
End If
Do While (True)
Array.Clear(Byte_Buffer, 0, Byte_Buffer.Length)
Int_Bytes = LobSocket.Receive(Byte_Buffer, Byte_Buffer.Length, 0)
output.Write(Byte_Buffer, 0, Int_Bytes)
If (Int_Bytes <= 0) Then
Exit Do
End If
Loop
output.Close()
If (LobSocket.Connected) Then
LobSocket.Close()
End If
Str_Reply = ServerReply(True)
Int_Reply = Int32.Parse(Str_Reply.Substring(0, 3))
If (Not (Int_Reply = 226 Or Int_Reply = 250)) Then
MsgBox(Str_Reply.Substring(4))
End If
End Sub
上传文件到FTP:
Public Sub UploadFile(ByVal Str_LocalFileName As String, ByVal Bool_Resume As Boolean)
Dim LobSocket As Socket
Dim offset As Long
Dim input As FileStream
Dim bFileNotFound As Boolean
If (Not Logined()) Then
Logined()
End If
LobSocket = CreateDataSocket()
offset = 0
If (Bool_Resume) Then
Try
SetBinaryMode(True)
offset = GetFileSize(Str_LocalFileName)
Catch ex As Exception
offset = 0
End Try
End If
If (offset > 0) Then
SendCommand("REST " & offset)
If (Int_Reply <> 350) Then
offset = 0
End If
End If
SendCommand("STOR " & Path.GetFileName(Str_LocalFileName))
Str_Reply = ServerReply(True)
Int_Reply = Int32.Parse(Str_Reply.Substring(0, 3))
If (Not (Int_Reply = 125 Or Int_Reply = 150)) Then
MsgBox(Str_Reply.Substring(4))
End If
bFileNotFound = False
If (File.Exists(Str_LocalFileName)) Then
input = New FileStream(Str_LocalFileName, FileMode.Open)
If (offset <> 0) Then
input.Seek(offset, SeekOrigin.Begin)
End If
Int_Bytes = input.Read(Byte_Buffer, 0, Byte_Buffer.Length)
Do While (Int_Bytes > 0)
LobSocket.Send(Byte_Buffer, Int_Bytes, 0)
Int_Bytes = input.Read(Byte_Buffer, 0, Byte_Buffer.Length)
Loop
input.Close()
Else
bFileNotFound = True
End If
If (LobSocket.Connected) Then
LobSocket.Close()
End If
If (bFileNotFound) Then
MsgBox(Str_LocalFileName & "文件未找到,无法上传")
End If
Str_Reply = ServerReply(True)
Int_Reply = Int32.Parse(Str_Reply.Substring(0, 3))
If (Not (Int_Reply = 226 Or Int_Reply = 250)) Then
MsgBox(Str_Reply.Substring(4))
End If
End Sub
Public Sub DownloadFile(ByVal Str_RemoteFileName As String, ByVal Str_LocalFileName As String, ByVal Bool_Resume As Boolean)
Dim Data_St As Stream
Dim output As FileStream
Dim LobSocket As Socket
Dim offset, npos As Long
If (Not Logined()) Then
Logined()
End If
SetBinaryMode(True)
If (Str_LocalFileName.Equals("")) Then
Str_LocalFileName = Str_RemoteFileName
End If
If (Not (File.Exists(Str_LocalFileName))) Then
Data_St = File.Create(Str_LocalFileName)
Data_St.Close()
End If
output = New FileStream(Str_LocalFileName, FileMode.Open)
LobSocket = CreateDataSocket()
offset = 0
If (Bool_Resume) Then
offset = output.Length
If (offset > 0) Then
SendCommand("REST " & offset)
Str_Reply = ServerReply(True)
Int_Reply = Int32.Parse(Str_Reply.Substring(0, 3))
If (Int_Reply <> 350) Then
offset = 0
End If
End If
If (offset > 0) Then
npos = output.Seek(offset, SeekOrigin.Begin)
End If
End If
SendCommand("RETR " & Str_RemoteFileName)
Str_Reply = ServerReply(True)
Int_Reply = Int32.Parse(Str_Reply.Substring(0, 3))
If (Not (Int_Reply = 150 Or Int_Reply = 125)) Then
MsgBox(Str_Reply.Substring(4))
End If
Do While (True)
Array.Clear(Byte_Buffer, 0, Byte_Buffer.Length)
Int_Bytes = LobSocket.Receive(Byte_Buffer, Byte_Buffer.Length, 0)
output.Write(Byte_Buffer, 0, Int_Bytes)
If (Int_Bytes <= 0) Then
Exit Do
End If
Loop
output.Close()
If (LobSocket.Connected) Then
LobSocket.Close()
End If
Str_Reply = ServerReply(True)
Int_Reply = Int32.Parse(Str_Reply.Substring(0, 3))
If (Not (Int_Reply = 226 Or Int_Reply = 250)) Then
MsgBox(Str_Reply.Substring(4))
End If
End Sub
上传文件到FTP:
Public Sub UploadFile(ByVal Str_LocalFileName As String, ByVal Bool_Resume As Boolean)
Dim LobSocket As Socket
Dim offset As Long
Dim input As FileStream
Dim bFileNotFound As Boolean
If (Not Logined()) Then
Logined()
End If
LobSocket = CreateDataSocket()
offset = 0
If (Bool_Resume) Then
Try
SetBinaryMode(True)
offset = GetFileSize(Str_LocalFileName)
Catch ex As Exception
offset = 0
End Try
End If
If (offset > 0) Then
SendCommand("REST " & offset)
If (Int_Reply <> 350) Then
offset = 0
End If
End If
SendCommand("STOR " & Path.GetFileName(Str_LocalFileName))
Str_Reply = ServerReply(True)
Int_Reply = Int32.Parse(Str_Reply.Substring(0, 3))
If (Not (Int_Reply = 125 Or Int_Reply = 150)) Then
MsgBox(Str_Reply.Substring(4))
End If
bFileNotFound = False
If (File.Exists(Str_LocalFileName)) Then
input = New FileStream(Str_LocalFileName, FileMode.Open)
If (offset <> 0) Then
input.Seek(offset, SeekOrigin.Begin)
End If
Int_Bytes = input.Read(Byte_Buffer, 0, Byte_Buffer.Length)
Do While (Int_Bytes > 0)
LobSocket.Send(Byte_Buffer, Int_Bytes, 0)
Int_Bytes = input.Read(Byte_Buffer, 0, Byte_Buffer.Length)
Loop
input.Close()
Else
bFileNotFound = True
End If
If (LobSocket.Connected) Then
LobSocket.Close()
End If
If (bFileNotFound) Then
MsgBox(Str_LocalFileName & "文件未找到,无法上传")
End If
Str_Reply = ServerReply(True)
Int_Reply = Int32.Parse(Str_Reply.Substring(0, 3))
If (Not (Int_Reply = 226 Or Int_Reply = 250)) Then
MsgBox(Str_Reply.Substring(4))
End If
End Sub
...全文
相关推荐
代码注释器
《代码注释器:理解和应用》在编程领域,代码注释器是一种极其重要的工具,它可以帮助程序员理解和翻译各种编程语言的代码,如C++和Java。
eclipse get/set方法自动加上字段注释
在"eclipse get/set方法自动加上字段注释"的场景中,当你在Eclipse中创建一个新属性或者选择已有属性时,可以通过右键点击属性选择"Source" -> "Generate Getters
sourceinsight 多行注释 批量注释 反注释
在Source Insight中,你可以这样做: - 使用查找与替换功能:打开查找对话框(`Ctrl+F`),在“查找”栏输入要注释的代码模式,然后在“替换”栏输入注释符号(例如`/*`)加上空格,接着选择
代码注释检测工具,用于进行代码注释统计
本话题将深入探讨代码注释检测工具及其在统计代码注释中的作用。CodeLineNet.exe 是一个专门用于进行代码注释统计的工具。
两段代码的区别
在QQ群中,有一个关于两段用于驱动显示设备的C语言代码的提问,这两段代码在处理延时和循环的方式上存在显著差别,从而影响到系统资源的使用效率和程序整体表现。


