65 pts.
 what is code of c/c++/java for search a file on local pc .program run on WINDOWSplateform
iam a MCA student .iwant to develop a c/c++/java code for search a file on my own pc in WINDOWS operating system enviornment.program must provide specific path or location of file.or say file not exists
ASKED: Mar 9, 2009  8:09 PM GMT
UPDATED: March 9, 2009  11:58:51 PM GMT
60,255 pts.

Answer Wiki:
I can't give you a complete solution, but hopefully this could point you in the right direction.

We did something similar once, but our app did not search in the complete file system, but only in the current directory.

The functions we needed to use were:

_chdir
_findfirst
_findnext
_findclose

Here's some example code (from a Microsoft page):

// crt_find.c
// This program uses the 32-bit _find functions to print
// a list of all files (and their attributes) with a .C extension
// in the current directory.

#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <time.h>

int main( void )
{
struct _finddata_t c_file;
intptr_t hFile;

// Find first .c file in current directory
if( (hFile = _findfirst( "*.c", &c_file )) == -1L )
printf( "No *.c files in current directory!\n" );
else
{
printf( "Listing of .c files\n\n" );
printf( "RDO HID SYS ARC FILE DATE %25c SIZE\n", ' ' );
printf( "--- --- --- --- ---- ---- %25c ----\n", ' ' );
do {
char buffer[30];
printf( ( c_file.attrib & _A_RDONLY ) ? " Y " : " N " );
printf( ( c_file.attrib & _A_HIDDEN ) ? " Y " : " N " );
printf( ( c_file.attrib & _A_SYSTEM ) ? " Y " : " N " );
printf( ( c_file.attrib & _A_ARCH ) ? " Y " : " N " );
ctime_s( buffer, _countof(buffer), &c_file.time_write );
printf( " %-12s %.24s %9ld\n",
c_file.name, buffer, c_file.size );
} while( _findnext( hFile, &c_file ) == 0 );
_findclose( hFile );
}
}


And here are some documentation links:

_chdir, _wchdir
_findfirst, _findfirst64, _findfirsti64, _wfindfirst, _wfindfirst64, _wfindfirsti64
_findnext, _wfindnext
_findclose

Hope this helps.
Last Wiki Answer Submitted:  Mar 9, 2009  11:58 PM (GMT)  by  Carlosdl   60,255 pts.
To see other answers submitted to the Answer Wiki View Answer History.
Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _