请问高手:为什么我用FTP会话连接时总出现Debug Assertion Failed!

prettywlazly 2011-05-01 10:57:57
主要代码如下:
  m_pInetSession=new CInternetSession(AfxGetAppName(),1,PRE_CONFIG_INTERNET_ACCESS);
m_pFtpConnection=m_pInetSession->GetFtpConnection("127.0.0.1","myway","123",21);

用FTP会话连接运行时总出现Debug Assertion Failed!
File:inet.cpp
Line:2347

请问是怎么个问题?
谢谢,回答的都有加分!
...全文
73 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Eleven 2011-05-01
  • 打赏
  • 举报
回复
Debug下调试一下看看各个指针值是否有效呢?
MSDN上给了一段FTP的示例代码,不妨参考一下:

// create a session object to initialize WININET library
// Default parameters mean the access method in the registry
// (that is, set by the "Internet" icon in the Control Panel)
// will be used.

CInternetSession sess(_T("My FTP Session"));

CFtpConnection* pConnect = NULL;

try
{
// Request a connection to ftp.microsoft.com. Default
// parameters mean that we'll try with username = ANONYMOUS
// and password set to the machine name @ domain name
pConnect = sess.GetFtpConnection(_T("ftp.microsoft.com"));

// use a file find object to enumerate files
CFtpFileFind finder(pConnect);

// start looping
BOOL bWorking = finder.FindFile(_T("*"));

while (bWorking)
{
bWorking = finder.FindNextFile();
_tprintf_s(_T("%s\n"), (LPCTSTR)finder.GetFileURL());
}
}
catch (CInternetException* pEx)
{
TCHAR sz[1024];
pEx->GetErrorMessage(sz, 1024);
_tprintf_s(_T("ERROR! %s\n"), sz);
pEx->Delete();
}

// if the connection is open, close it
if (pConnect != NULL)
{
pConnect->Close();
delete pConnect;
}
oyljerry 2011-05-01
  • 打赏
  • 举报
回复
触发了异常,你单步调试一下代码

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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