Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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();


}
Posted
Updated 3-Aug-19 5:17am
v2
Comments
Richard MacCutchan 3-Aug-19 4:47am    
I think you need to upgrade your programming to modern standards. The use of basic dos functions became obsolete years ago.

First off, "I cant ..." doesn't tell us anything about the problem you are having - we know you have a problem or you wouldn't be posting here, but we can't see your screen, access your HDD, tell what you typed, or read your mind!
So start by learning how to ask a question: remember the above, and that we get no context beyond exactly what you type - so it's important to give us information:
What have you tried?
Where are you stuck?
What have you done to try and find out what the problem is?
What help do you need?
The better your question, the better our answer!

Secondly, indent your code: A single indent for the one any only function you write isn't enough, you need to indent each time you add an if, an else, a while, or a for to make your code readable.

Thirdly, stop commenting what the instruction is doing, and comment why you are doing it:
textcolor(2);  // for a text color in c programming
Is a useless comment:
textcolor(2);  // Set to Green test
Is much better,
but:
textcolor(GREEN);
Doesn't need a comment at all ... Apply that to all your code: comment why you do something, not what your code is doing - we can see that because we can read the code!

Finally, your code doesn't try to use chmod - it doesn't even compile with the current code:
test=system(C:\\Windows\\System32\\ipconfig);//chmod is command to hide the folder or file

Only show us code that compiles if you want us to help you with running code, because unless it compiles, it won't run! And show us the code that does run, and explain what happens when you run it, along with the actual values in any variables (use the debugger to work out exactly what they are - don't guess or assume!)
 
Share this answer
 
Comments
Nephacker 3-Aug-19 12:13pm    
Sir,i wanna hide file / folder by using _chmod in c programming. I cant hide my folder by using _chmod("FA,1,1FA_SYSTEM | FA_HIDDEN | FA_RDONLY"); i have a problem this code code dosent hiding folder or file from harddrive
 
Share this answer
 
Comments
Nephacker 3-Aug-19 12:25pm    
sir, how can hide files and folder by using _chmod in c programming? whats type of Tributes i have to use to hide folder files in c programming
Richard MacCutchan 3-Aug-19 12:52pm    
Try using one of the constant values with the _A_ prefix in the dos.h header file.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900