您的位置:首页 > 其它

读取文件夹或者文件中的内容

2011-05-27 14:08 197 查看
CString get_path()//获取当前程序工作的目录
{
TCHAR szFilePath[MAX_PATH];
DWORD dwFLen=::GetModuleFileName(_AtlBaseModule.GetModuleInstance(),szFilePath,MAX_PATH);

//其中_AtlBaseModule.GetModuleInstance()可以为null
CString sPath=szFilePath;
int i=sPath.ReverseFind('//');
if(i>0) sPath=sPath.Left(i);
return sPath;
}

int main()
{
CString strDir=get_path()+_T("//Torrents//*.*");
HANDLE hFind;
WIN32_FIND_DATA fd;
CString filename;
CString strTmp;

hFind=::FindFirstFile((LPCTSTR)strDir,&fd);
if(hFind==INVALID_HANDLE_VALUE) return 0;
do{
if(!strcmp(fd.cFileName,_T("."))||!strcmp(fd.cFileName,_T("..")))
continue;
if(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)
{
CString name=strDir+fd.cFileName;

}
filename=fd.cFileName;
int i=filename.Find(_T(".torrent"),0);
if(i!=-1)
{
strTmp=strDir+filename;
strTmp=get_path()+_T("//Torrents//DownloadTorrents.ini");

CString savepath;
::GetPrivateProfileString("DownLad_Torrents",strTmp,"c://secbt",savepath.GetBuffer(MAX_PATH),MAX_PATH,strTmp);

}
}while(::FindNextFile(hFind,&fd));

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐