1.VBåftpä¸ä¼ å·¥å
·
VBåftpä¸ä¼ å·¥å ·
å¨VBä¸å®ç°æ件ä¸ä¼
VisualBasicä½ä¸ºä¸ä¸ªéåºç¨ç¨åºå¼åãæµè¯ãæ¥éåè½äºä¸ä½çéæå¼å¼åç¯å¢,源码 拼团è¶æ¥è¶åå°ç¨åºåçéçãç¬è å¨å¼åææ°æ®åºç»´æ¤ç³»ç»çè¿ç¨ä¸,éæ©äºVB5.0ä½ä¸ºå¼åå¹³å°,Unixä½ä¸ºæå¡å¨ç«¯æä½ç³»ç»,Informixä½ä¸ºæå¡å¨æ°æ®åºã
é®é¢çåºç°
å¨å¼å该维æ¤ç³»ç»çè¿ç¨ä¸,注æå°Informixæ°æ®åºçå段类åCLOBå¡«å ¥æ°æ®æ¶éè¦å½æ°FILETOCLOB("FILENAME","SERVER"),å ¶ä¸ç"FILENAME"éè¦æåºæ件路å¾åæ件å称ãç¶è,å¨ç»´æ¤è¿ç¨ä¸æ¤æ件æ¯å¨å®¢æ·ç«¯æ§è¡ç,è¿æ ·å°±è¦æ±å³æ¶å°æä»¶ä¼ è¾å°æå¡å¨ç«¯ã
解å³åæ³
1.FTPä¼ è¾å·¥å ·
æ们é¦å 使ç¨FTPä¼ è¾å·¥å ·,ç¨VB5.0ä¸SHELLå½ä»¤è°ç¨DOSæ¹å¤çæ件æ¥å®ç°ä¼ è¾çéè¦ã
Shellè°ç¨æ ¼å¼:
Shell(pathname[,windowstyle])
ä¾å:Shell("c:\windows\upload.bat")
æ¹å¤çæ件upload.batçå 容:
c:\windows\ftphostname
username
password
sendc:\zrh\upload.txtupload.txt
bye
该å½ä»¤å®ç°äºæ件"upload.txt"çä¼ è¾è¦æ±ãå¨ä½¿ç¨å®æ¯ä¹å,åè°ç¨å½ä»¤æ该æ件å é¤ã
ä¾å:Shell("c:\windows\del_up.bat")
æ¹å¤çæ件del_up.batçå 容:
c:\windows\ftphostname
username
password
deleupload.txt
bye
è¿æ ·,æ件"upload.txt"被å é¤ã
ä½æ¯,å¦ä¸ä¸ªé®é¢åºç°äºãç±äºShellå½æ°çè¿è¡æºå¶æ¯ä¸å ¶å®ç¨åºåæ¥æ§è¡,ä¹å°±æ¯è¯´,å½è°ç¨Shellå½æ°çåç¨åºè¿æ²¡ææ§è¡å®æ¯ä¹å,Shellå½æ°åé¢çè¯å¥å·²ç»æ§è¡ãå¨å¤§æ¹éæ·»å æ°æ®çè¿ç¨ä¸,å°±ä¼åºç°æ个记å½çæ件è¿æ²¡æä¼ å°,èä¸ä¸ä¸ªæå ¥è¯å¥(Insert)å·²ç»å¼å§è°ç¨ãè¿æ ·,ODBCè°ç¨å°±ä¼åºç°é误ã
2.INETæ§ä»¶
InternetTransferæ§ä»¶æä¾äºInternetä¸æ常使ç¨ç两ç§åè®®:HTTPåFTPã使ç¨HTTPåè®®å¯ä»¥è¿æ¥å°WWWæå¡å¨ä¸æ¥ä¸è½½æ件;使ç¨FTPåè®®åå¯ä»¥ç»å½å°FTPæå¡å¨ãä¸è¬çFTPå½ä»¤,ä¾å¦CDãGETé½å¯ä»¥éè¿Executeæ¹æ³å®ç°ã
ä¸é¢æ¯ä¸ä¸ªè®¾ç½®INETæ§ä»¶å±æ§çä¾åã
inet1.URL=ftp://username:password@hostname/document
inet1.Protocol=2-icFTP
inet1.RemoteHost=hostname
inet1.RemotePort=
inet1.Username=username
inet1.Password=password
æ§è¡æä»¶ä¼ è¾:
Inet1.Execute"ftp://username:password@hostname",_
"PUT"&local_filename&"UPLOAD1.TXT"
right1=Inet1.StillExecuting
DoWhileright1
right1=Inet1.StillExecuting
DoEvents
Loop
è¿æ ·ä¾¿å®ç°äºæ件çä¸è½½ã
*SINETæ§ä»¶çä¼ç¹
INETæ§ä»¶ä¸Shell()å½æ°çä¸åä¹å¤å¨äºINETæ§ä»¶éè¿è°ç¨è¯å¥
right1=Inet1.StillExecuting
DoWhileright1
right1=Inet1.StillExecuting
DoEvents
Loopæ¥æ§å¶è¯å¥æ§è¡ç顺åºãå¨æä»¶ä¼ è¾å·¥ä½æªå®æä¹å,ç¨åºä¸ä¼æ§è¡å ¶å®è¯å¥,èªç¶ä¹å°±ä¸ä¼åºç°è°ç¨Shellå½æ°æåºç°çé®é¢ãåéright1ç¨æ¥æµè¯inet1çæ§è¡ç¶æ,å¦æè¿ç¨ä¸ä»å¨è¿è¡æä»¶ä¼ è¾çå·¥ä½,åè°ç¨è¿ç¨DoEventsç»ç³»ç»ç©ºé²æ¶é´æ¥åæä»¶ä¼ è¾å·¥ä½,è¿æ ·ä¾¿æåå°æ§è¡äºæ件ä¸è½½çåè½ã该æ件使ç¨å®æ¯ä¹åå°è¢«å é¤ã
Inet1.Execute"ftp://informix:informix@rd",_
"DELETEUPLOAD1.TXT"
right1=Inet1.StillExecuting
DoWhileright1
right1=Inet1.StillExecuting
DoEvents
Loop
å°ä¸è½½çæ件å é¤æ¯ä¸ºäºé¿å å ç¨æå¡å¨ç«¯ç£ç空é´ã
*Så©ç¨StateChangedäºä»¶æ示信æ¯
æå¡å¨å¨æ§è¡inet1.executeçåæ¶ä¹æ¿æ´»äºInet1_StateChangedäºä»¶,è¿ç¨å¯ä»¥æ ¹æ®æè·å°çç¶æè¿è¡å¨ä½ã
object_StateChanged(ByValStateAsInteger)
State:æ´æ°ç±»åInteger
ä¸é¢æ¯ç¶æç说æã
常æ°å¼ æè¿°icNone
0 æªæ¥åç¶æicHostResolvingHost
1 æ§ä»¶æ£å¨å¯»æ¾æå®ä¸»æºçIPå°åicHostResolved
2 æ§ä»¶å·²æåæ¾å°æå®ä¸»æºçIPå°åicConnecting
3 æ§ä»¶æ£å¨ä¸æå®ä¸»æºè¿è¡è¿æ¥icConnected
4 æ§ä»¶å·²æåä¸æå®ä¸»æºè¿æ¥icRequesting
5 æ§ä»¶æ£å¨å主æºååºè¯·æ±icRequestSent
6 æ§ä»¶å·²æåå主æºååºè¯·æ±icReceivingResponse
7 æ§ä»¶æ£å¨ä»ä¸»æºæ¥æ¶åé¦ä¿¡æ¯icResponseReceived
8 æ§ä»¶å·²æåä»ä¸»æºæ¥ååé¦ä¿¡æ¯icDisconnecting
9 æ§ä»¶æ£å¨ä¸ä¸»æºæå¼icDisconnected
æ§ä»¶å·²ä¸ä¸»æºæå¼icError
å¨ä¸ä¸»æºéä¿¡çè¿ç¨ä¸åçäºé误icResponseCompleted
请æ±ç»æä¸æ°æ®å·²ç»æ¥æ¶å°
ä¸é¢æ¯ä¸ä¸ªä¾åã
PrivateSubInet1_StateChanged(ByValStateAsInteger)
'RetrieveserverresponseusingtheGetChunk
'methodwhenState=.Thisexampleassumesthe
'dataistext.
SelectCaseState
'...Othercasesnotshown.
CaseicResponseReceived'
DimvtDataAsVariant'Datavariable.
DimstrDataAsString:strData=""
DimbDoneAsBoolean:bDone=False
'Getfirstchunk.
vtData=Inet1.GetChunk(,icString)
DoWhileNotbDone
strData=Data&vtData
'Getnextchunk.
vtData=Inet1.GetChunk(,icString)
IfLen(vtData)=0Then
bDone=True
EndIf
Loop
txtData.Text=strData
EndSelect
EndSub->