Boost C++ Libraries: Ticket #13576: boost filesystem create_directories function fails randomly when accessing to a mapped network drive https://svn.boost.org/trac10/ticket/13576 <p> When trying to create a folder in a mapped network drive with boost filesystem create_directories function, I get random errors of type: "The system cannot find the path specified.". By random I mean that sometimes I get the error and sometimes I don't. </p> <p> And yes, I have checked: </p> <ul><li>It is a valid path. </li><li>It is not a too long path. In fact, I use windows extended path as \?\PATH. </li><li>The network drive works perfectly, and it is inside our company local network (Gigabit ethernet). </li><li>I have write permissions. </li><li>There are not unicode characters. </li></ul><p> Below the code (adapted to make it more simple). </p> <pre class="wiki">#include "boost/filesystem.hpp" #include &lt;string&gt; #include &lt;chrono&gt; #include &lt;thread&gt; #include &lt;iostream&gt; #define MAX_RETRIES 10 #define RETRY_TIME 5000 //in millisecond namespace fs = boost::filesystem; bool createDirectory(const std::string&amp; folderPath) { //If the function does not succeed to create the directory in first place, it will retry after RETRY_TIME miliseconds a maximum number of MAX_RETRIES. for (unsigned int i=0; i&lt;MAX_RETRIES; i++) { try { if (fs::create_directories(fs::path(folderPath))) { std::cerr &lt;&lt; "Folder created successfully!" &lt;&lt; std::endl; return true; } } catch (fs::filesystem_error const &amp; e) { std::cerr &lt;&lt; "File operation problem with files: " &lt;&lt; e.what() &lt;&lt;". Try number: "&lt;&lt;i+1&lt;&lt;std::endl; } if (i==MAX_RETRIES-1) { return false; } std::this_thread::sleep_for(std::chrono::milliseconds(RETRY_TIME)); } return true; } </pre><p> In this example I am trying to create the folder: </p> <p> Z:\PRIVATE_FOLDERS\XXX\tests\YYY\ZZZZZ\MMMMMMM\CCCCCC\@mmmm1\@ccccc1\@eeeeeeeee2 (Z is a network mapped drive): </p> <p> And here is the output. Sometimes it works the first time </p> <pre class="wiki">Folder created successfully! </pre><p> Sometimes it fails several consecutive times until it works. Magic? </p> <pre class="wiki">File operation problem with files: "boost::filesystem::create_directories: The system cannot find the path specified: "\\?\Z:\PRIVATE_FOLDERS\XXX\tests\YYY\ZZZZZ\MMMMMMM\CCCCCC\@mmmm1\@ccccc1\@eeeeeeeee2"". try number: 1 File operation problem with files: "boost::filesystem::create_directories: The system cannot find the path specified: "\\?\Z:\PRIVATE_FOLDERS\XXX\tests\YYY\ZZZZZ\MMMMMMM\CCCCCC\@mmmm1\@ccccc1\@eeeeeeeee2"". try number: 2 File operation problem with files: "boost::filesystem::create_directories: The system cannot find the path specified: "\\?\Z:\PRIVATE_FOLDERS\XXX\tests\YYY\ZZZZZ\MMMMMMM\CCCCCC\@mmmm1\@ccccc1\@eeeeeeeee2"". try number: 3 Folder created successfully! </pre><p> The problem of this implementation is that, a priori there is no way to differentiate if the input path is a network drive, or it is a wrong path or does not have write permissions. Therefore I need always to spend the MAX_RETRIES until it finally fails, with the consequent performance penalty. </p> <p> Notes: </p> <ul><li>I am on Windows 10 </li><li>Boost version is 1.60 built on VS2015 downloaded from official webpage. </li><li>I use intel compiler 17 for the rest of the code. </li></ul> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13576 Trac 1.4.3