Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) boost::filesystem::copy_file

 

boost::filesystem::copy_file is a Boost.Filesystem file I/O function to copy a file.

 

#include <cassert>
#include <boost/filesystem.hpp>

int main()
{
  const std::string from = "from.txt";
  const std::string to = "to.txt";
  assert(boost::filesystem::is_regular_file(from)
    && "Assume file is present");
  boost::filesystem::copy_file(from,to);
}

 

 

 

 

 

Qt Creator Note for Qt Creator users

 

Add the following line to your project file (to prevent the link error undefined reference to 'boost::system::get_system_category()'):

 

LIBS += -lboost_system -lboost_filesystem

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict