vb 怎么用winsoc控件 ftp上传下载文件
急求vb 怎么用winsock控件 ftp上传下载文件,还有没有其他的做法,简单就好
只上传下载就行 --------------------编程问答-------------------- 大虾们,没人吗 --------------------编程问答--------------------
VERSION 5.00--------------------编程问答-------------------- Inet1.userName = "***"
Object = "{48E59290-9880-11CF-9754-00AA00C00908}#1.0#0"; "MSINET.OCX"
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
ClientHeight = 3060
ClientLeft = 45
ClientTop = 330
ClientWidth = 4035
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3060
ScaleWidth = 4035
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "下载"
Height = 495
Left = 1440
TabIndex = 0
Top = 1320
Width = 1215
End
Begin InetCtlsObjects.Inet Inet1
Left = -15
Top = -15
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim ExeStr As String
Dim Done As Boolean
Private Sub cmd(cmdstr As String)
Do
If Inet1.StillExecuting = False Then Exit Do
Loop
ExeStr = cmdstr
Done = False
Debug.Print ExeStr; "="
Inet1.Execute , ExeStr
Do
DoEvents
If Done Then Exit Do
Loop
End Sub
Public Sub DownLoadFile(filenameext As String)
Inet1.URL = "ftp://xxx.xxx.xx.xxx"
Inet1.UserName = "username"
Inet1.Password = "password"
'cmd "PWD"
'cmd "DIR"
'cmd "GET " + filenameext + App.Path + "\" + filenameext
cmd "GET " + filenameext + App.Path + "\" + filenameext
cmd "QUIT"
End Sub
Private Sub Command1_Click()
Command1.Enabled = False
DownLoadFile ("filenameext")
Command1.Enabled = True
End Sub
Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim intFile As Integer
Dim vtData() As Byte
Dim str As String
'On Error GoTo ISCerr
Debug.Print "State="; State,
Select Case State
Case 0
Debug.Print "icNone"
Case 1
Debug.Print "icHostResolvingHost"
Case 2
Debug.Print "icHostResolved"
Case 3
Debug.Print "icConnecting"
Case 4
Debug.Print "icConnected"
Case 5
Debug.Print "icRequesting"
Case 6
Debug.Print "icRequestSent"
Case 7
Debug.Print "icReceivingResponse"
Case 8
Debug.Print "icResponseReceived"
If Left(ExeStr, 2) = "CD" Then Done = True
Case 9
Debug.Print "icDisconnecting"
Case 10
Debug.Print "icDisconnected"
Done = True
Case 11
Debug.Print "icError of [" + ExeStr + "]="; Inet1.ResponseInfo
Done = True
Case 12
Debug.Print "icResponseCompleted----------------"
Do
str = Inet1.GetChunk(1024, icString)
If LenB(str) = 0 Then Exit Do
Debug.Print str
Loop
Done = True
End Select
Exit Sub
ISCerr:
Resume Next
End Sub
Inet1.password = "***$$33"
Inet1.Protocol = icFTP
Inet1.RemoteHost = ""
Inet1.RemotePort = 21
Inet1.AccessType = icUseDefault
Inet1.Execute "", "PUT " & txtUploadPath.Text & " aaa.xls"
ri = Inet1.StillExecuting
Do While ri
ri = Inet1.StillExecuting
DoEvents
Loop
我这样写也不报错,什么反应都没有,文件没传上去,什么问题?? --------------------编程问答--------------------
补充:VB , 网络编程