简体   繁体   English

如何在boost :: filesystem中使用copy_file?

[英]How to use copy_file in boost::filesystem?

I want to copy a file from directory to another, but my program always aborts for some reasons.Has anyone done this this before could tell me what was wrong? 我想将一个文件从目录复制到另一个文件,但我的程序总是因为某些原因而中止。有没有人这样做之前可以告诉我出了什么问题? And how could I catch exceptions was thrown by copy_file , I checked boost site, but I could not find any relevant information about exception. 我怎么能捕获copy_file引发的异常,我检查了boost站点,但是我找不到任何有关异常的相关信息。

path user_path( "C:\\My Folder" );
boost::filesystem::create_directory( user_path );
path file(  "C:\\Another\\file.txt" );
boost::filesystem::copy_file( file, user_path );

Thanks, 谢谢,

您必须提供文件名的路径,而不仅仅是它所在的目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM