-1

MY CURRENT CODE

#include<windows.h>
#include<fstream>
#include<direct.h>
#include<conio.h>
#include<sys/stat.h>
#include<filesystem>

int main(){
    int choice;
    std::string folder_n;

    std::cin >> choice;

    if(choice == 2){
        std::cout << "Enter folder name" << std::endl;
        std::cin >> folder_n;

        filesystem::create_directory(folder_n);
        std::cout << "created folder named " << folder_n << std::endl ;
            
    }

    return 0;
}

MY PROBLEM --> error: 'filesystem' has not been declared can anybody tell why is this error coming and how to fix it

Note : 1. filesystem is included in my c++ version because intellisense is showing filesystem
       2. I am using MinGw 
       3. My MinGW version is 9.2.0```
Malay Joshi
  • 3
  • 1
  • 3
  • 3
    Missing `#include `, `#include `. Unnecessary `#include `, `#include `, `#include `, `#include `, `#include `. And finally missing `std::` on `filesystem::create_directory`. – Eljay Apr 16 '22 at 11:46
  • Possible duplicate: https://stackoverflow.com/questions/50960492/creating-folders-in-c – vishal Apr 16 '22 at 11:47
  • Try `std::filesystem::create_directory`, or `std::experimental::filesystem::create_directory` if you have an old standard lib. – wohlstad Apr 16 '22 at 11:52
  • done that now this error ---> name followed by '::' must be a class or namespace name – Malay Joshi Apr 16 '22 at 12:01
  • Make sure that your version of mingw is using c++17. Related: [https://stackoverflow.com/questions/44734397/which-c-standard-is-the-default-when-compiling-with-g](https://stackoverflow.com/questions/44734397/which-c-standard-is-the-default-when-compiling-with-g) – drescherjm Apr 16 '22 at 13:40

1 Answers1

0

Create_directory works only with c++ 17.

In compiling, try g++ -std=c++17 file.cpp.

This is the site for all the file system function here

XmanJob
  • 1
  • 5