我用INET控件写了一个FTP下载,请用如何用这个控件得到FTP空间里某一个文件的大小?(在线等)

天锋 2004-07-23 01:25:06
我用INET控件写了一个FTP下载,请用如何用这个控件得到FTP空间里某一个文件的大小?

同样,我如何得到我本地硬盘中的某的文件的大小?

谢谢!
...全文
169 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
klan 2004-09-15
  • 打赏
  • 举报
回复
取本地文件大小用fileLen不就行了?
幻影时空 2004-09-15
  • 打赏
  • 举报
回复
取得本地的文件大小:

Private Declare Function GetCompressedFileSize Lib "kernel32" Alias "GetCompressedFileSizeA" (ByVal lpFileName As String, lpFileSizeHigh As Long) As Long

VsFileSize=GetCompressedFileSize("C:\win.rar", 1024)
msgbox VsFileSize
klan 2004-09-13
  • 打赏
  • 举报
回复
ftp 中有size这个命令嘛?
online 2004-07-25
  • 打赏
  • 举报
回复
其实就是size命令,正确执行后,执行Inet1_StateChanged的Case 12中的过程
使用getchunk接收
Inet1.GetChunk(1024, 0) '0表示把数据作为字符串来检索,1表示把数据作为字节数组来检索

附完整代码
Dim OperationStyle As Integer
Dim filesize As Long

Private Sub Command1_Click()

Dim StrMsg As String
Dim isbusy As Boolean

Inet1.URL = "ftp://192.168.0.1/"
Inet1.Protocol = icFTP
Inet1.UserName = ""
Inet1.Password = ""

StrMsg = "Dir"
Inet1.Execute , StrMsg

End Sub

Private Sub Command3_Click()
OperationStyle = 2
Inet1.Execute , "size wq.rar"
End Sub

Private Sub Inet1_StateChanged(ByVal State As Integer)
Select Case State
Case 1
Text1.Text = "is looking"
Case 2
Text1.Text = "success finding "
Case 3
Text1.Text = "is connecting"
Case 4
Text1.Text = "success connected"
Case 5
Text1.Text = "is sending request"
Case 6
Text1.Text = "sucess sending"
Case 7
Text1.Text = "is receiving"
Case 8
Text1.Text = "success receive"
Case 9
Text1.Text = "is disconnecting"
Case 10
Text1.Text = "success disconnect"
Case 11
Text1.Text = "is error"
Case 12 'icResponseCompleted
Text1.Text = "success receive data"
Select Case OperationStyle
Case 2
filesize = Inet1.GetChunk(1024, 0)
MsgBox CStr(filesize)
Case Else
End Select
End Select
End Sub
天锋 2004-07-24
  • 打赏
  • 举报
回复
tttttttttttttttttttttttt
天锋 2004-07-24
  • 打赏
  • 举报
回复
ttttttttttttttttttttt
天锋 2004-07-24
  • 打赏
  • 举报
回复
我的FTP空间打不开了,正在弄。
online 2004-07-23
  • 打赏
  • 举报
回复
你有ftp空间吗?我需要测试以下
天锋 2004-07-23
  • 打赏
  • 举报
回复
谢谢楼上的朋友。问题是:

我用label1.Caption =size 文件 不对啊。请帮忙讲得详细一点好吗?
online 2004-07-23
  • 打赏
  • 举报
回复
inet提供了size命令
size file1
返回file1所指定的文件大小
Inet1.Execute , "size " & 远程目录 & 文件
天锋 2004-07-23
  • 打赏
  • 举报
回复
tttt
天锋 2004-07-23
  • 打赏
  • 举报
回复
楼上的朋友提供的只是取得本地硬盘的文件的大小,怎样用INTEL控件取得FTP空间里文件的大小呢?
online 2004-07-23
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
Dim fso, f
Set fso = CreateObject("scripting.filesystemobject")
Set f = fso.getfile("c:\new.mdb")
MsgBox f.Size & "字节"
End Sub

1,502

社区成员

发帖
与我相关
我的任务
社区描述
VB 网络编程
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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