CInternetFile *file=NULL;
try
{
// We know for sure this is an internet file.
// so the cast is safe
file = (CInternetFile *)session.OpenURL(URL);
}
catch(CInternetException *pEx)
{
// if anything went wrong, just set file to NULL
file = NULL;
pEx->Delete();
}
if (file)
{
m_out += "Connection established. \r\n";
CString line;
for (int i=0; i<20 && file->ReadString(line); i++)
{
m_out += line + "\r\n";
}
file->Close();
delete file;
}
else
{
m_out += "No server found there. \r\n";
}