what is code of c/c++/java for search a file on local pc .program run on WINDOWSplateform

65 pts.
Tags:
C
Development
Java
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

Answer Wiki

Thanks. We'll let you know when a new response is added.

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):
<pre>
// 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 );
}
}</pre>

And here are some documentation links:

<a href=”http://msdn.microsoft.com/en-us/library/bf7fwze1.aspx”>_chdir, _wchdir</a>
<a href=”http://msdn.microsoft.com/en-us/library/zyzxfzac(VS.71).aspx”>_findfirst, _findfirst64, _findfirsti64, _wfindfirst, _wfindfirst64, _wfindfirsti64</a>
<a href=”http://msdn.microsoft.com/en-us/library/6tkkkc1y.aspx”>_findnext, _wfindnext</a>
<a href=”http://msdn.microsoft.com/en-us/library/0165cecc.aspx”>_findclose</a>

Hope this helps.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following