FTP问题,请帮忙解释下该代码的意义
一个FTP上传代码的例子。其中有3句不太理解,请高手指教下,谢谢
【Dim byt(1024) As Byte】 【intCount = fs.Read(byt, 0, 1024 + 1) 】 【 st.Write(byt, 0, intCount) 】
imports System.Net
Imports System.IO
Public Class Form1
Private Sub btnFtp_Click(sender As Object, e As EventArgs) Handles btnFtp.Click
Dim frq As FtpWebRequest, frp As FtpWebResponse
Dim st As Stream, fs As FileStream
Dim byt(1024) As Byte, intCount As Integer ‘’‘’‘’‘’ 这里 byt(1024) 有啥意思,可以调大吗? 起到什么作用
如果我上传文件3M多,是不是这里也要改?
Try
frq = CType(WebRequest.Create(txtFtp.Text), FtpWebRequest)
frq.Credentials = New NetworkCredential(txtUser.Text, txtPassword.Text)
frq.Method = WebRequestMethods.Ftp.UploadFile
frq.KeepAlive = True
st = frq.GetRequestStream()
fs = New FileStream(txtFile.Text, FileMode.Open, FileAccess.Read)
Do While True
intCount = fs.Read(byt, 0, 1024 + 1) ;---请问这句是什么意思,BYT大小对其有啥影响
If intCount > 0 Then
st.Write(byt, 0, intCount) ;---请问这句是什么意思,BYT大小对其有啥影响
Else
Exit Do
End If
Loop
st.Close() '
fs.Close()
frp = CType(frq.GetResponse, FtpWebResponse)
frp.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
MsgBox("完成!")
End Sub
End Class