How to find out if a folder exists and how to create a folder?

前端 未结 3 1189
灰色年华
灰色年华 2021-02-05 11:20

I\'m trying to create a folder if it doesn\'t exist. I\'m using Windows and I am not interested on my code working in other platforms.

Never mind, I found the solution.

相关标签:
3条回答
  • 2021-02-05 11:52

    Use boost::filesystem::exists to check if file exists.

    0 讨论(0)
  • 2021-02-05 11:55

    boost::filesystem::create_directories does just that: Give it a path, and it will create all missing directories in that path.

    0 讨论(0)
  • 2021-02-05 12:07

    The POSIX-compatible call is mkdir. It silently fails when the directory already exists.

    If you are using the Windows API, then CreateDirectory is more appropriate.

    0 讨论(0)
提交回复
热议问题