Click here to Skip to main content
14,385,373 members

Code to hide folder or file by C programming?

Nephacker asked:

Open original thread
I Cant hide files or folder by using #include<io.h>,#include<dos.h> by using
_chmod(FN,1,FA_SYSTEM | FA_HIDDEN | FA_RDONLY);

What I have tried:

#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<io.h>
void main()
{
	int i,test; //test for condition in c programming
	char ch,FN[20];  //fn mean file name-ch mean to choice a number in switch
	char s[]={"#FILE/FOLDER PROTECTION SOFTWARE !"};
	clrscr();
	gotoxy(14,5);
	textcolor(2);
	cprintf("_______________________________________________");
	gotoxy(14,6);
	cprintf("_______________________________________________");
	gotoxy(14,10);
	cprintf("_______________________________________________");
	gotoxy(18,8);
	textcolor(10);
	for(i=0;s[i]!='\0';i++) //to show the header which is declear in char
	{
	_setcursortype(1);
	cprintf("%c",s[i]);
	delay(50);
	sound(1500);
	delay(50);
	nosound();
	}
	textcolor(2);  // for a text color in c programming
	gotoxy(22,12);
	cprintf("1 :HIDE A FILE /FOLDER ");
	gotoxy(22,14);
	cprintf("2 :SHOW A FILE /FOLDER ");
	gotoxy(22,16);
	cprintf("3 :HELP ");

	gotoxy(10,24);
	cprintf("Designed & Developed At Nepha6ker.blogspot.com Copyright @ 2019 ");
	gotoxy(16,18);
	cprintf("       ENTER YOUR CHOICE :->> ");
	ch=getch(); //when the user press esc than it exit the program
	if(ch==27)
	exit(1);
	switch(ch)
	{
	case '1':clrscr();
	gotoxy(15,6);
	textcolor(2);
	cprintf("______________________________________________________");
	gotoxy(15,7);
	cprintf("______________________________________________________");
	gotoxy(15,12);
	cprintf("______________________________________________________");
	gotoxy(17,9);
	cprintf("ENTER THE FILE / FOLDER NAME WITH PATH !!");
	gotoxy(17,11);
	cprintf("$ : ");
	fflush(stdin);//to clear all the screen which has run when started
	gets(FN);
	test=test=_chmod(FN,1,FA_SYSTEM || FA_HIDDEN || FA_RDONLY);//chmod is command to hide the folder or file
	if(test==-1)
	{
	clrscr();
	gotoxy(19,9);
	sound(1000);
	delay(200);
	cprintf("Unable to hide file / folder ! ");
	nosound();
	}
	else
	{
	clrscr();
	gotoxy(19,9);
	cprintf("Operation executed successfully !");
	nosound();
	}

	break;
	}



getch();


}
Tags: C

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100