Skip to main content

Create and Remove Directory in C++

 


#include<bits/stdc++.h>
#include<Windows.h>

using namespace std;




   //----------CREATE DIRECTORY--------------
int main(){

    BOOL bDir;
    bDir = CreateDirectoryA("D:/simple/ok",NULL);
    if (bDir == FALSE)
    {
        cout<<"Faild to Create"<<GetLastError()<<endl;
    }
    cout<<"Created Directory Successfully "<<endl;


    //----------REMOVE DIRECTORY-------------
//     string a;
//     cout<<"If you want to delete directory type Y/y ";
//    cin>>a;
//     if(a == "Y"|| "y")
// {
//     bDir = RemoveDirectoryA("D:\\simple\\ok");
//     if (bDir == FALSE)
//     {
//         cout<<"Remove Directory is faild"<<GetLastError()<<endl;
//     }
//     cout<<"Successfully Removed Directory"<<endl;
// }
// else{
//     cout<<"Not Deleted";
// }
    system("PAUSE");
    return 0;
}

Comments