没有合适的资源?快使用搜索试试~ 我知道了~
获取ftp服务器文件的大小,从而可以设置下载的进度条
资源推荐
资源详情
资源评论
Public Function GetFileSize(ByVal remoteFile As String,
ByVal host As String,
ByVal username As String,
ByVal password As String) As Long
'创建FtpWebRequest类实例
Dim URI As String = host & remoteFile
Dim ftp As System.Net.FtpWebRequest = CType(FtpWebRequest.Create(URI), FtpWebRequest)
'通信凭据主要是用户名和密码
ftp.Credentials = New System.Net.NetworkCredential(username, password)
'设置ftp方法为获取文件的大小
ftp.Method = System.Net.WebRequestMethods.Ftp.GetFileSize
'设置请求完后销毁连接
ftp.KeepAlive = False
'设置传输类型为文本
ftp.UseBinary = False
ftp.Method = System.Net.WebRequestMethods.Ftp.GetFileSize
'获取请求回应
Dim ftpresponse As FtpWebResponse = CType(ftp.GetResponse, System.Net.FtpWebResponse) '/返回响应
'获取文件长度
Dim longstream As Long = ftpresponse.ContentLength
ByVal host As String,
ByVal username As String,
ByVal password As String) As Long
'创建FtpWebRequest类实例
Dim URI As String = host & remoteFile
Dim ftp As System.Net.FtpWebRequest = CType(FtpWebRequest.Create(URI), FtpWebRequest)
'通信凭据主要是用户名和密码
ftp.Credentials = New System.Net.NetworkCredential(username, password)
'设置ftp方法为获取文件的大小
ftp.Method = System.Net.WebRequestMethods.Ftp.GetFileSize
'设置请求完后销毁连接
ftp.KeepAlive = False
'设置传输类型为文本
ftp.UseBinary = False
ftp.Method = System.Net.WebRequestMethods.Ftp.GetFileSize
'获取请求回应
Dim ftpresponse As FtpWebResponse = CType(ftp.GetResponse, System.Net.FtpWebResponse) '/返回响应
'获取文件长度
Dim longstream As Long = ftpresponse.ContentLength
资源评论
要点理想色彩
- 粉丝: 45
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功