file system create directory permissions problem in windows
Hi, I am trying to create a directory in my temp folder in windows. Using this sintax : boost::filesystem::remove_all(tcd); boost::filesystem::create_directory(boost::filesystem::path(tcd)); tcd is a char* that looks like : "%TEMP%\file_123456" I get the error "the system can not find the patch" If I use _mkdir. I also get an error. Is there anything that I am missing to create directories in the env. variable temp in windows? The code works just fine in linux. Thanks Jose
I am trying to create a directory in my temp folder in windows. Using this sintax :
boost::filesystem::remove_all(tcd); boost::filesystem::create_directory(boost::filesystem::path(tcd));
tcd is a char* that looks like :
"%TEMP%\file_123456"
I get the error "the system can not find the patch"
Hi Jose, I haven't personally used environment variables with boost::filesystem and can't find any mention of it in the documentation. So I would assume that it is not supported. You'll probably need to expand the environment variables in the path before it to boost::filesystem. Alternatively, if you're only using %TEMP% to determine the temp folder, you might as well use temp_directory_path(): boost::filesystem::path tcd = boost::filesystem::temp_directory_path() / "file_123456"; Also keep in mind that remove_all() will throw if the directory does not exist. Either use the non-throwing remove_all() or check if the directory exists using is_directory(). -- Best regards, Martin Dyring-Andersen SPAMfighter ApS
participants (2)
-
Jose
-
Martin Dyring-Andersen