高手能帮我给这两段代码加上注释么?

xlh0053 2010-06-23 08:59:11
从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
...全文
196 21 打赏 收藏 转发到动态 举报
写回复
用AI写文章
21 条回复
切换为时间正序
请发表友善的回复…
发表回复
w3vip 2010-08-14
  • 打赏
  • 举报
回复
我来得分了
xlh0053 2010-08-14
  • 打赏
  • 举报
回复
来个人得分吧
xlh0053 2010-08-13
  • 打赏
  • 举报
回复
算了,我还是结贴吧
yanlongwuhui 2010-07-13
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 xlh0053 的回复:]
我要是看懂了还需要去加注释吗?你们真是太幽默了
[/Quote]
这么一段代码,总不可能每句都进行注释吧,会吓死人的。
应该把看不懂需要别人进行注释的位置标记下,这样大家才能针对性的进行注释
Ghost_Khz 2010-07-13
  • 打赏
  • 举报
回复
又是一个体力活。。 。。。。。。悲剧。。 。大大的悲剧。
wuxing2006 2010-07-13
  • 打赏
  • 举报
回复
FTP协议,你看看就懂了
然后对着协议拿telnet 手动看下就明了
xlh0053 2010-07-13
  • 打赏
  • 举报
回复
xlh0053 2010-07-01
  • 打赏
  • 举报
回复
xlh0053 2010-06-29
  • 打赏
  • 举报
回复
我要是看懂了还需要去加注释吗?你们真是太幽默了
xlh0053 2010-06-28
  • 打赏
  • 举报
回复
看样子要结贴了
snwvf6688 2010-06-28
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 lwd203 的回复:]
你把这些代码看懂了不就能加上注释了?
[/Quote]
ok
xlh0053 2010-06-26
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 lwd203 的回复:]
你把这些代码看懂了不就能加上注释了?
[/Quote]
我就是看不懂才叫大家帮我加注释啊
xlh0053 2010-06-25
  • 打赏
  • 举报
回复
msdn不是网站吗?
qq234121906 2010-06-25
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 xlh0053 的回复:]
msdn不是网站吗?
[/Quote]


帮助文档,安装在本地的。
lwd203 2010-06-25
  • 打赏
  • 举报
回复
你把这些代码看懂了不就能加上注释了?
周公 2010-06-24
  • 打赏
  • 举报
回复
装个MSDN,不懂的函数看看MSDN就行了嘛。
周公 2010-06-24
  • 打赏
  • 举报
回复
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
xlh0053 2010-06-24
  • 打赏
  • 举报
回复
来人帮忙啊
xlh0053 2010-06-23
  • 打赏
  • 举报
回复
我晕,F10调试能自动添加注释啊?
我知道结果,我想知道这个过程的意思啊
Justin-Liu 2010-06-23
  • 打赏
  • 举报
回复
F10调试一下

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧