D
dylb
Unregistered / Unconfirmed
GUEST, unregistred user!
各位大虾:
如何用Delphi远程打开ftp站点上text文件,并进行读取和写入,我觉得把文件先
下载,再改再上传的方式太麻烦了点,如何在线进行读取和写入呢?
补充:
在网络上找到一段C++的代码,可以实现读写,哪位大虾帮忙翻译为Delphi,谢谢!
DWORD FtpWriteRead(char * cFtpHost,char * cFile,DWORD dwLen,char * buf,char cFlag)
{
HINTERNET hInternet,hHost,hFile;
DWORD dwLength,dwError;
hInternet=InternetOpen(“FZYXB",LOCAL_INTERNET_ACCESS,NULL,0,0);
hHost=InternetConnect(hInternet,cFtpHost,INTERNET_INVALID_PORT_NUMBER,
“fzxucm",“abc505",INTERNET_SERVICE_FTP,INTERNET_FLAG_PASSIVE,0);
if ( cFlag == 0 ) // 写
hFile=FtpOpenFile(hHost,cFile,GENERIC_WRITE,FTP_TRANSFER_TYPE_BINARY,0);
else
hFile=FtpOpenFile(hHost,cFile,GENERIC_READ,FTP_TRANSFER_TYPE_BINARY,0);
if( !hFile)
{
if ( (dwError=GetLastError()) == 12003 )
ShowMsg(hWin,“ 文 件 不 存 在");
InternetCloseHandle(hHost);
InternetCloseHandle(hInternet);return 0L;
}
if ( cFlag == 0 )
InternetWriteFile(hFile,buf,dwLen, &dwLength);
else
InternetReadFile(hFile,buf,dwLen, &dwLength);
InternetCloseHandle(hFile);InternetCloseHandle(hHost);
InternetCloseHandle(hInternet);
return dwLength;
}
如何用Delphi远程打开ftp站点上text文件,并进行读取和写入,我觉得把文件先
下载,再改再上传的方式太麻烦了点,如何在线进行读取和写入呢?
补充:
在网络上找到一段C++的代码,可以实现读写,哪位大虾帮忙翻译为Delphi,谢谢!
DWORD FtpWriteRead(char * cFtpHost,char * cFile,DWORD dwLen,char * buf,char cFlag)
{
HINTERNET hInternet,hHost,hFile;
DWORD dwLength,dwError;
hInternet=InternetOpen(“FZYXB",LOCAL_INTERNET_ACCESS,NULL,0,0);
hHost=InternetConnect(hInternet,cFtpHost,INTERNET_INVALID_PORT_NUMBER,
“fzxucm",“abc505",INTERNET_SERVICE_FTP,INTERNET_FLAG_PASSIVE,0);
if ( cFlag == 0 ) // 写
hFile=FtpOpenFile(hHost,cFile,GENERIC_WRITE,FTP_TRANSFER_TYPE_BINARY,0);
else
hFile=FtpOpenFile(hHost,cFile,GENERIC_READ,FTP_TRANSFER_TYPE_BINARY,0);
if( !hFile)
{
if ( (dwError=GetLastError()) == 12003 )
ShowMsg(hWin,“ 文 件 不 存 在");
InternetCloseHandle(hHost);
InternetCloseHandle(hInternet);return 0L;
}
if ( cFlag == 0 )
InternetWriteFile(hFile,buf,dwLen, &dwLength);
else
InternetReadFile(hFile,buf,dwLen, &dwLength);
InternetCloseHandle(hFile);InternetCloseHandle(hHost);
InternetCloseHandle(hInternet);
return dwLength;
}