Aca les dejo un code q me oculta un File:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char dir[70];
char orden_dir[50];
char nomFile[30];
char barra[] = "\x5C";
char orden[54];
int op;
do
{
system("cls");
system("Title Ocultar File Gedzac - by sowher");
system("color 7");
printf("\n\t----------Menu------------\n");
printf("\t[1]. Ocultar Archivo\n");
printf("\t[2]. Mostrar Archivo Oculto\n");
printf("\t[3]. Salir\n");
printf("\t-----------------------------\n");
printf("\tElija la opcion: ");
fflush(stdin);
scanf("%d", &op);
fflush(stdin);
switch (op)
{
case 1:
system("cls");
printf("\n\tEscriba el ruta del File (Ej: C:%sruta ): ", barra);
fflush(stdin);
gets(dir);
printf("\tLa ruta elegido es: %s\n", dir);
strcpy(orden_dir,"cd ");
strcat(orden_dir,dir);
while (system(orden_dir) == 1)
{
printf("\tLa ruta no existe, vuelva a intentarlo\n");
printf("\tEscriba el ruta del File (Ej: C:%sruta): ", barra);
gets (dir);
printf("\tLa ruta elegido es: %s\n", dir);
strcpy(orden,"cd ");
strcat(orden,dir);
}
strcpy(orden_dir,"cd ");
strcat(orden_dir,dir);
system(orden_dir);
fflush(stdin);
printf("\n\tIntroduzca el nombre del File (Ej: file.txt): ");
gets(nomFile);
printf("\tEl File elegido es: %s\n", nomFile);
strcpy(orden,"dir ");
strcat(orden,dir);
strcat(orden,barra);
strcat(orden,nomFile);
while (system(orden) == 1)
{
printf("El File no existe, vuelva a intentarlo");
printf("Introduzca el nombre del File(Ej: file.txt): ");
gets(nomFile);
printf("El archivo elegido es: %s\n", nomFile);
strcpy(orden,"dir ");
strcat(orden,dir);
strcat(orden,barra);
strcat(orden,nomFile);
}
strcpy(orden,"attrib ");
strcat(orden,dir);
strcat(orden,barra);
strcat(orden,nomFile);
strcat(orden," +h");
system(orden);
break;
case 2:
system("cls");
printf("\n\tEscriba el ruta del File (Ej: C:%sruta ): ", barra);
fflush(stdin);
gets(dir);
printf("\tLa ruta elegido es: %s\n", dir);
strcpy(orden_dir,"cd ");
strcat(orden_dir,dir);
while (system(orden_dir) == 1)
{
printf("\tLa ruta no existe, vuelva a intentarlo\n");
printf("\tEscriba el ruta del File (Ej: C:%sruta): ", barra);
gets (dir);
printf("\tLa ruta elegido es: %s\n", dir);
strcpy(orden,"cd ");
strcat(orden,dir);
}
strcpy(orden_dir,"cd ");
strcat(orden_dir,dir);
system(orden_dir);
fflush(stdin);
printf("\n\tIntroduzca el nombre del File (Ej: file.txt): ");
gets(nomFile);
printf("\tEl File elegido es: %s\n", nomFile);
strcpy(orden,"dir ");
strcat(orden,dir);
strcat(orden,barra);
strcat(orden,nomFile);
while (system(orden) == 1)
{
printf("El File no existe, vuelva a intentarlo");
printf("Introduzca el nombre del File(Ej: file.txt): ");
gets(nomFile);
printf("El archivo elegido es: %s\n", nomFile);
strcpy(orden,"dir ");
strcat(orden,dir);
strcat(orden,barra);
strcat(orden,nomFile);
}
strcpy(orden,"attrib ");
strcat(orden,dir);
strcat(orden,barra);
strcat(orden,nomFile);
strcat(orden," -h");
system(orden);
break;
case 3:
exit (0);
break;
default:
printf("\tOpcion no valida");
}
}while (op!=3);
return 0;
}
Compilado en Dev-C++ 4.9.9.2