读取文件夹或者文件中的内容
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));
}
{
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));
}
相关文章推荐
- 读取同一文件夹下多个txt文件中的特定内容并做统计
- Java web 项目读取src或者tomcat下class文件夹下的xml文件或者properties文件
- 本机远程执行命令,查看其他机器的文件内容或者文件夹内容
- python2.7学习之读取文件夹下所有文件名称及内容
- 读取两个压缩包,比较文件夹及文件内容的不同之处并添加到另一个文件夹打包下载
- node遍历文件夹并读取文件内容
- java读取文件夹中文件,并复制内容到另一个文件中
- Java如何读取数据文件,如txt文件或者.dat文件 中的内容
- 读取两个excl文件和图片文件夹 并将其中的图片文件移动其他文件夹excl内容上传数据库
- Day27、文件夹内容的读取、软连接和硬链接文件、fctl文件锁的操作、Mycp.c
- c++ 读取整个文件内容 || VC 检查创建文件夹
- shell读取文件夹里的文件内容并输出
- 实现快速读写配置文件的内容,可以用于读取*.exe.config文件或者Web.Config文件的内容,或者可以读取指定文件的配置项.
- File:迭代读取文件夹下的文件或者文件夹
- 读取文件夹下所有文件内容
- Matlab 读取父文件下子文件夹内容
- [003]从文件夹中读取所有图片或者文件
- 解决vs2013网站发布时漏掉部分文件或者文件夹中的内容
- Java之遍历文件夹下的文件,以及读取内容并Copy到另一文件夹下
- Android 关于文件及文件夹的创建 、删除、重命名、复制拷贝、添加内容、修改内容、读取内容