标题:vfp控制ftp问题,
取消只看楼主
dxnn520
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-9-4
 问题点数:0 回复次数:3 
vfp控制ftp问题,

版主大人,我的vfp水平不高,看到大家都能用vfp程序上传下载文件,我花了2个月的时间,下载了n个程序和源代码,可就是行不通,不是搞不懂参数就是执行出错,或者传不上去,看在我对vfp痴情的份上,哪位好心人能帮我发一个“绝对、绝对、绝对”能用的vfp访问ftp的程序,我用1000...个鞠躬来谢了!

搜索更多相关主题的帖子: vfp ftp 源代码 
2006-09-04 18:18
dxnn520
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-9-4
得分:0 
* 上传文件到 ftp 上*------------------------------------------------
Clea
#Define INTERNET_INVALID_PORT_NUMBER 0
#Define INTERNET_OPEN_TYPE_DIRECT 1
#Define INTERNET_SERVICE_FTP 1
#Define FTP_TRANSFER_TYPE_ASCII 1
#Define FTP_TRANSFER_TYPE_BINARY 2
Public hOpen, hFtpSession
Do decl
* select FTP connection provi* you an appropriate access level
* in all cases it can not be any "anonymous" access
If connect2ftp ("222.73.4.75", "csjwn520", "152123")
* select the existing source and valid target file names
* these names are as an example only
lcSource = "f:\ftp\ftp.txt" &&不知道是什么意思?
lcTarget = "红雨/temptest.txt" &&不知道是什么意思?
lcRenamed = "红雨/角色代理.prg" &&不知道是什么意思?
* default transfer type selected -
* the file is transfered exactly as it is
If FtpPutFile (hFtpSession, lcSource,;
lcTarget, FTP_TRANSFER_TYPE_BINARY, 0) = 1
* if file (lcRenamed) already exists, most probably it would be replaced
* with the new one during the renaming
* at least my FTP server acts like this
? FtpRenameFile (hFtpSession, lcTarget, lcRenamed)
Endif
= InternetCloseHandle (hFtpSession)
= InternetCloseHandle (hOpen)
Endif
Procedure decl
Declare INTEGER InternetOpen IN wininet.dll;
STRING sAgent,; INTEGER lAccessType,;
STRING sProxyName,;
STRING sProxyBypass,;
STRING lFlags
Declare INTEGER InternetCloseHandle IN wininet.dll INTEGER hInet
Declare INTEGER InternetConnect IN wininet.dll;
INTEGER hInternetSession,;
STRING sServerName,;
INTEGER nServerPort,;
STRING sUsername,;
STRING sPassword,;
INTEGER lService,;
INTEGER lFlags,;
INTEGER lContext
Declare INTEGER FtpPutFile IN wininet.dll;
INTEGER hConnect,;
STRING lpszLocalFile,;
STRING lpszNewRemoteFile,;
INTEGER dwFlags,;
INTEGER dwContext
Declare INTEGER FtpRenameFile IN wininet.dll;
INTEGER hConnect,;
STRING lpszExisting,;
STRING lpszNew
Return
Endproc
Function connect2ftp (strHost, strUser, strPwd)
* open access to Inet functions
hOpen = InternetOpen ("vfp", INTERNET_OPEN_TYPE_DIRECT, 0, 0, 0) && 提示参数出错!出错!出错!出错!
* hOpen = InternetOpen("vfp",INTERNET_OPEN_TYPE_DIRECT,0,0,0)
If hOpen = 0
? "找不到库 WinInet.Dll 的入口"
Return .F.
Endif
* connect to FTP
hFtpSession = InternetConnect (hOpen, strHost, INTERNET_INVALID_PORT_NUMBER,;
strUser, strPwd, INTERNET_SERVICE_FTP, 0, 0)
If hFtpSession = 0
* close access to Inet functions and exit
= InternetCloseHandle (hOpen)
? "FTP " + strHost + " 无效"
Return .F.
Else
? "连接到 " + strHost + " as: [" + strUser + ", *****]"
Endif
Return .T.
Endfunc
*------------------------ 提示“参数不对!”
2006-09-04 18:18
dxnn520
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-9-4
得分:0 

我用http://www.gz9f.com/bbs/printpage.asp?BoardID=1&ID=225405下载源码传输,出现“文件找不到提示!”

DIMENSION ftptranfile(1,7)
ftptranfile(1,1)='REMOTESEND' && REMOTESEND—发送 HOSTSEND—接收
ftptranfile(1,2)='ftp.txt' && 需要传输的文件名(字符型,可包含通配符)
ftptranfile(1,3)='ftp://222.73.4.75/' ; && 远程目录(字符型)
ftptranfile(1,4)='f:\' && 本地目录(字符型)
ftptranfile(1,5)=' ' && 返回传输结果(字符型) 空
&& 保留元素,无需赋值
ftptranfile(1,7)=' ' && 返回结束传输时间(字符型) 空

DO FORM f:\ftp\ftp\ftp.scx WITH '222.73.4.75','csjwn520','4250',ftptranfile,1024

? ftptranfile(1,5)
? ftptranfile(1,7)

2006-09-04 18:18
dxnn520
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-9-4
得分:0 
大家下载一下,都试试呀!这么好,都没有人用呀!太可惜了!
2006-09-05 11:13



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-87965-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.426761 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved