Скачиваний:
20
Добавлен:
01.05.2014
Размер:
1.62 Кб
Скачать
#include <cstdlib>
#include <iostream>
#include <Windows.h>

using namespace std;

int main(int argc, char *argv[])
{   
    cout<<"\t\tLaboratory work number 3"<<endl;
    //***Создание директории***
    char path_name[100];
    cout<<"Input path for your catalog:";
    cin>>path_name;                        //Ввод имени каталога который создаем
     if(CreateDirectory(path_name,0)!=0)  //Создание каталога с заданным именем
     {
     cout<<"Directory was created!"<<endl;                                     
     }
     else
     {
     cout<<"Error!\t"<<GetLastError()<<endl;   
     }
    
    //***Удаление директории***
    char button;
    while(button!='y')
    {
    cout<<"Press 'y' when you will ready remove created directory.";
    cin>>button;                   
    } 
    RemoveDirectory(path_name);
    cout<<"Directory was removed";
    
    //***Перемещение файла***
    char file_name[100];
    char new_file_name[100];
    cout<<endl<<"Input file name:";
    cin>>file_name;
    cout<<"Input new file name:";
    cin>>new_file_name;
    if(MoveFile(file_name,new_file_name)!=0)
    {
    cout<<"File was renamed!";                                         
    }
    else
    {
    cout<<"Error!\t"<<GetLastError();    
    }
    
    //***Удаление файла***
    button='\0';
    while(button!='y')
    {
    cout<<endl<<"Press 'y' when you will ready remove renamed file.";
    cin>>button;                   
    }
    DeleteFile(new_file_name);
    cout<<"File was removed"<<endl;
    system("PAUSE");
    return EXIT_SUCCESS;
}
Соседние файлы в папке Лабораторная работа 3