18,356
社区成员
发帖
与我相关
我的任务
分享
{
UpdateData(true);
CStdioFile file2;
CString outfilename;
CString outhtml;
int filelist = 0;
int iout,j;
char drive[_MAX_DRIVE];
char dir[_MAX_DIR];
TCHAR exeFullPath[MAX_PATH];
GetModuleFileName(NULL,exeFullPath,MAX_PATH);
_splitpath(exeFullPath, drive, dir, NULL,NULL);
do
{
outfilename.Format("%s%sout%d.lst", drive, dir,filelist);
filelist++;
}
while (PathFileExists(outfilename));
file2.Open(outfilename,CFile::modeCreate| CFile::modeWrite);
for (j=0;j<i;j++)
{
file2.WriteString(m_strFornt);//前缀如“HTTP://”
file2.WriteString(AstrOut.GetAt(j));//AstrOut就是URL数组
file2.WriteString("\n");
}
file2.Close();
outhtml.Format("%d个文件被处理!;采集到%d个有效数据",ifile,i);
MessageBox(outhtml);
}
BOOL CXiazaiDlg::MyRead()
{
UpdateData(true);
CString strTmp;
CString FileTitle;
CString filename;
m_Source.MakeLower();
if (m_Source.Left(7) == "http://")//如果输入是网址直接下载
{
arrUrl.Add(m_Source);
if (!PathFileExists(m_OutPath))
{
arrOutFile.Add(m_OutPath);
}
else
{
if (m_Source.Find('?') == -1)//有的网址有“?”今天就遇到了。
{
strTmp = m_Source.Right(m_Source.GetLength()-1-m_Source.ReverseFind('/'));
}
else
{
strTmp = m_Source.Right(m_Source.GetLength()-1-m_Source.ReverseFind('?'));
strTmp += ".htm";
}
filename.Format("%s\\%s",m_OutPath,strTmp);
arrOutFile.Add(filename);
}
iNum++;
}
else if (PathFileExists(m_Source))//输入的是列表文件名
{
CStdioFile filein;
if (filein.Open(m_Source,CFile::modeRead))
{
while (filein.ReadString(strTmp))//这里读取列表,读的没有错误
{
if (strTmp != "")
{
arrUrl.Add(strTmp);
if (strTmp.Find('?') == -1)
{
strTmp = strTmp.Right(strTmp.GetLength()-1-strTmp.ReverseFind('/'));
}
else
{
strTmp = strTmp.Right(strTmp.GetLength()-1-strTmp.ReverseFind('?'));
strTmp += ".htm";
}
filename.Format("%s\\%s",m_OutPath,strTmp);
arrOutFile.Add(filename);
iNum++;
}
}
if (iNum == 1)
{
if (!PathFileExists(m_OutPath))
{
arrOutFile[0] = m_OutPath;
}
}
filein.Close();
}
else
{
MessageBox("列表读取失败!");
}
}
else
{
return false;
}
return true;
}