1

I need help on how to add "everyone" to the folder's share option property using c++.

this is my code on how to create new folder

#include <direct.h>
    int main()
    {
          mkdir("c:/scan");
          return 0;
    }

1 Answers1

2

According to the documentation, following should create a directory, and set permissions to give all users access:

namespace fs = std::filesystem;
fs::create_directory(path);
fs::permissions(path, fs::perms::all);
eerorika
  • 232,697
  • 12
  • 197
  • 326
  • i tried to run this #include #include #include #include namespace fs = std::filesystem; int main() { fs::create_directory("C:/newscan"); fs::permissions(path, fs::perms::all); } and got this following error 4 35 D:\kerja\Untitled2.cpp [Error] experimental/filesystem: No such file or directory – Dwi Novitasari Aug 08 '19 at 04:32
  • 1
    @DwiNovitasari make sure you have the compiler set to compile to the c++ 17 Standard revision. Exactly how you do this with your development tools should be documented by those development tools. – user4581301 Aug 08 '19 at 14:38
  • @DwiNovitasari Also note that the path needs to be the same for both calls. `fs::path dir = "C:/newscan"; fs::create_directory(dir); fs::permissions(dir, fs::perms::all);` – Ted Lyngmo Aug 08 '19 at 17:14
  • @TedLyngmo hello it gives me new error instead c:\mingw\mingw\include\c++\8.2.0\bits\fs_path.h|237|error: no match for 'operator!=' (operand types are 'std::filesystem::__cxx11::path' and 'std::filesystem::__cxx11::path')| – Dwi Novitasari Aug 09 '19 at 08:08