16,554
社区成员
发帖
与我相关
我的任务
分享
'WebClient对象作成
Dim wc As New System.Net.WebClient()
'指定用户名和密码
wc.Credentials = New System.Net.NetworkCredential("username", "password")
'从FTP服务器下载
wc.DownloadFile("ftp://localhost/test.txt", "C:\test.txt")
'释放资源
wc.Dispose()
'WebClient对象作成
Dim wc As New System.Net.WebClient()
'指定用户名和密码
wc.Credentials = New System.Net.NetworkCredential("username", "password")
'向FTP服务器上传文件
wc.UploadFile("ftp://localhost/test.txt", "C:\test.txt")
'释放资源
wc.Dispose()
'下载
Dim dfile As New WebClient
dfile.DownloadFile(Me.M_Url, Me.M_FileName)
'上传
Dim dfile As New WebClient
dfile.UploadFile(Me.M_Url, Me.M_FileName)
'获得ftp文件大小
Dim reqFtp As FtpWebRequest
reqFtp = CType(FtpWebRequest.Create(New Uri(url)), FtpWebRequest)
reqFtp.Proxy = Nothing
reqFtp.Method = WebRequestMethods.Ftp.GetFileSize
Dim response As WebResponse
response = reqFtp.GetResponse()
Return response.ContentLength()