How to delete a folder in C++?

后端 未结 16 1329
悲&欢浪女
悲&欢浪女 2020-12-03 00:45

How can I delete a folder using C++?

If no cross-platform way exists, then how to do it for the most-popular OSes - Windows, Linux, Mac, iOS, Android? Would a POSIX

16条回答
  •  时光取名叫无心
    2020-12-03 01:26

    This works for deleting all the directories and files within a directory.

    #include 
    #include 
    #include 
    using namespace std;
    int main()
    {
        cout << "Enter the DirectoryName to Delete : ";
        string directoryName;
        cin >> directoryName;
        string a = "rmdir /s /q " + directoryName;
        system(a.c_str());
        return 0;
    }
    

提交回复
热议问题