您的位置:首页 > 其它

Boost FileSystem 库使用说明2

2013-05-30 11:17 323 查看
#include <boost/filesystem.hpp>

#include <boost/filesystem/operations.hpp>

using namespace boost::filesystem;

//文件属性

CString strPath=_T("d:\\a.txt");

wpath p(strPath.GetBuffer());

bool bIsDirectory=is_directory(p);

wstring sPath=p.wstring();

wstring sroot_path=p.root_path().wstring();

wstring sleaf=p.leaf().wstring();

wstring sfilename=p.filename().wstring();

wstring sExtension=p.extension().wstring();

CString str;

str.Format(_T("bIsDirectory = %d \npath= %s \nsExtension= %s \n sroot_path= %s \n sfilename= %s \nsleaf= %s"),

bIsDirectory,

sPath.c_str(),

sExtension.c_str(),

sroot_path.c_str(),

sfilename.c_str(),

sleaf.c_str());

AfxMessageBox(str);

//遍历目录所有文件

directory_iterator diend;

for (directory_iterator pos("d:\\");pos!=diend; ++pos)

{

wpath p=pos->path();

wstring s=p.wstring();

CString str;

str.Format(_T("%s %d"),s.c_str(),is_directory(p));

AfxMessageBox(str);

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