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);
}
#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);
}
相关文章推荐
- boost.pool源码整理和使用说明
- boost.lexical_cast源码整理和使用说明
- 【Boost】boost库asio详解5——resolver与endpoint使用说明
- Boost1.58—— thread组件使用说明
- windows下boost怎样安装与使用说明
- [转]QTCreator + MSVC10编译器 使用boost::filesystem 时 error LNK2019: codecvt ... 问题的解决
- Boost::filesystem的使用笔记
- 【Boost】boost库asio详解4——deadline_timer使用说明
- 使用boost中的filesystem类库遍历某个目录所有的文件
- 使用boost::filesystem实现目录遍…
- windows下boost怎样安装与使用说明
- QTCreator + MSVC10编译器 使用boost::filesystem 时 error LNK2019: codecvt ... 问题的解决
- 【Boost】boost库asio详解4——deadline_timer使用说明
- 使用boost.filesystem进行文件操作
- 【Boost】boost库asio详解5——resolver与endpoint使用说明
- boost----windows下boost怎样安装与使用说明
- Boost.Asio C++ 网络编程之十一:deadline_timer使用说明
- 【Boost】boost库asio详解5——resolver与endpoint使用说明
- 使用Qt的qmake管理boost::filesystem代码时出现LNK2019问题
- 【Boost】boost库asio详解5——resolver与endpoint使用说明