27.
Program to create and delete a directory?
Program
#include<stdio.h>
#include<conio.h>
#include<dos.h>
void create();
void del();
char str[20];
union REGS in,out;
void main()
{
int ch;
clrscr();
do
{
clrscr();
printf("\n\nMENU:\n\t1.CREATE DIRECTORY\n\t2.DELETE DIRECTORY\n\t3.EXIT");
printf("\nENTER YOUR CHOICE:");
scanf("%d",&ch);
switch(ch)
{
case 1:create();
break;
case 2:del();
break;
case 3:printf("EXITING!!!!");
exit(0);
}
}while((ch==1)||(ch==2));
getch();
}
/*----Creating the Directory----*/
void create()
{
int k=0;
printf("\nEnter the path:"); //set the path of the directory
scanf("%s",&str);
in.h.ah=0X39;
in.x.dx=FP_OFF(str); //load the DX register with the path
int86(0X21,&in,&out);
k=out.x.cflag;
if(k==0) //check the status of C flag
printf("\nCREATION SUCCESSFUL!!!");
else
printf("\nCREATION NOT POSSIBLE!!!");
}
/*----Deleting the Directory----*/
void del()
{
int k=0;
printf("Enter the path:"); //set the path of the directory to be deleted
scanf("%s",&str);
in.h.ah=0X3A;
in.x.dx=FP_OFF(str); //load the DX register with the path
int86(0X21,&in,&out);
k=out.x.cflag;
if(k==0) //check the status of C flag
printf("\nDELETION SUCCESSFUL");
else
printf("\nDELETION NOT POSSIBLE!!!");
}
Output
MENU:
1.CREATE DIRECTORY
2.DELETE DIRECTORY
3.EXIT
ENTER
YOUR CHOICE:1
Enter
the path:Z:\ABC
CREATION
SUCCESSFUL!!!
MENU:
1.CREATE DIRECTORY
2.DELETE DIRECTORY
3.EXIT
ENTER
YOUR CHOICE:2
Enter
the path:Z:\ABC
DELETION
SUCCESSFUL
MENU:
1.CREATE DIRECTORY
2.DELETE DIRECTORY
3.EXIT
ENTER
YOUR CHOICE:3
EXITING!!!!
No comments:
Post a Comment