Click here to Skip to main content
15,893,337 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
but in my code specific folder can be hide what I want is when I click Hide ALL the fodler must hide not only ONE folder...

C#
#include<iostream>
#include<string.h>
//#include<stdlib.h>
#include<conio.h>
#include<process.h>

using namespace std;
main()
{
      FILE *p;
      char ch,s[100];
      char r[100]="ren ";

      //hide
      char u[]=" \"Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}\"\n attrib +h +s \"Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}\"";
      //unhide
      char h[]="attrib -h -s \"Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}\"\nren \"Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}\" ";
      char v[50];
      int choice,i;


      p=fopen("D:\\a.bat","w+");
      if(p==NULL)
      {
           cout<<"Error in opening the file a.c";
           getch();
           exit(0);
      }

       cout<<"Enter choice :\n";
       cout<<"1.Hide Folder/File\n";
       cout<<"2.UnHide folder/File\n";
       cout<<"3.Exit \n";
       cin>>choice;

       switch(choice)
       {
        case 1:
             cout<<"Enter new name of your folder/file: ";
             fflush(stdin);
             gets(v);
             strcat(r,v);
             strcat(r,u);
        //     cout<<r;
             fputs(r,p);
             break;


        case 2:
             strcpy(r,"");
             strcat(r,h);
             cout<<"Enter new name of your folder/file: ";
             fflush(stdin);
             gets(v);
             strcat(r,v);
             fputs(r,p);
             break;

             default:
                     fclose(p);
                     remove("D:\a.bat");
                     system("pause");
                     exit(0);
        }


        fclose(p);
        system("D:\\a.bat");
        remove("D:\\a.bat");
        //system("pause");
        getch();
}
Posted
Comments
Chuck O'Toole 3-Mar-12 14:51pm    
You do realize that none of this works if the user enters a filename with a space in it
Sergey Alexandrovich Kryukov 3-Mar-12 19:18pm    
Not just that. Hard-coded h[] and u[]... hopeless. Using hidden attribute it practically useless.
The whole idea is wrong. What would be the purpose?
--SA

create a batch file in that
execute command "ATTRIB +H *.*"
 
Share this answer
 
Comments
reikuxian 3-Mar-12 9:32am    
ATTRIB +H *.* is in my code the problem is it only hide to one folder..what i want is to hide ALL Folder..
If you're wanting to hide all folders and files starting at a given folder, you can use the attrib +h *.* /s

The /s will include all subitems from the current folder.

Hope this helps.
 
Share this answer
 
Comments
reikuxian 3-Mar-12 10:21am    
it doesnt work any..it will prompt "The syntax of the command is incorrect"
Chuck O'Toole 3-Mar-12 11:05am    
Jeez, doesn't anybody know how to do things for themselves. "Attrib /?" will give you help on the command. Use that, Learn. Or would you rather we do all the work for you?
reikuxian 3-Mar-12 11:26am    
im just having difficulty in hiding ALL Folder not only a specif folder...
krmed 3-Mar-12 11:46am    
Why are you putting all the "control panel" stuff in your batch file? The only thing you need in the batch file should be the attrib +h c:\whateverdir\*.* /s command.
Chuck O'Toole 3-Mar-12 14:52pm    
he's "hiding" it my moving it into some magic subfolder of "control panel" as well as setting the attribute. Whatever floats his boat.

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