Discussion Locked

C++ file operations

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
If possible, how do I create directories with C++ code? Also, can I then assign security rights to those directories using C++?

1 reply

by emmenjay

You cannot create or manage directories using standard, portable, C++. However most C++ compilers provide platform-specific methods to do this.

On a Unix or Linux system you would create a directory using mkdir() and set access permissions usingchmod() and chown().

If you are using VC++ on Windows, you can use _mkdir() to create a directory (or _wmkdir() to create a directory with a Unicode name) and then _chmod() or _wchmod() to set basic access permissions. However, a more flexible way is to use CreateDirectory() which allows you to specify a security descriptor.

This discussion is closed to new replies.