Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file handling question in platform SDK... not MFC

Status
Not open for further replies.

Vallurupa

Programmer
Oct 17, 2001
38
US
I have to read the directory and subdirectories in the directory. I have to read all file in the directory and compare with the other directory with the same structure, if it finds any file leaves it other wise it has to move files to the new directory with the same structure.


MAILBOX ---- SUBDIR1
---- SUBDIR2
---- SUBDIR3

SENTBOX ---- SUBDIR1
---- SUBDIR2
---- SUBDIR3

OUTBOX ----SUBDIR1
----SUBDIR2
----SUBDIR3


here the logic is, it has to check the mailbox with the sent box items. If any files are not sent then we have to send them to OUTBOX with the same directory stracture..
anyone can pelase help me the logic...

i have to write code in SDK.. like findfirstfile() functions.. I have get the whole path of the file...

thanks in advance..

venkat

 
Hi Venkat,

I can help you with the Searching :
BOOL FileOperation(TCHAR *strSrc, TCHAR* strDest)
{
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
hFind = FindFirstFile(strSrc, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
{
printf ("Invalid File Handle. Get Last Error reports %d\n", GetLastError ());
}
else
{
BOOL bNotFinished = FALSE;
while ( !bNotFinished )
{
if ( FindNextFile(hFind, &FindFileData) )
{
if ( _tcsicmp(FindFileData.cFileName,_T(".")) && _tcsicmp(FindFileData.cFileName, _T("..")) )
{
TCHAR src[MAX_PATH], dest[MAX_PATH];
_tcsset(src, 0);
_tcsset(dest, 0);
_tcscpy(src, tcsSrcpath);
_tcscat(src, FindFileData.cFileName);
_tcscpy(dest, strDest);
_tcscat(dest, FindFileData.cFileName);
if ( !MoveFileEx(src, dest, OVEFILE_WRITE_THROUGH) )
{
//!!Display Error
}
}
}
else
{
if (GetLastError() == ERROR_NO_MORE_FILES)
{
bNotFinished = TRUE;
}
}
}
FindClose(hFind);
}

Now this function you can again call for the Subsirectory using recursion.
Do let me know if this helps you.

Regards,
Sun
 
Hi Sun,

Thank you so much..
I am working on it. It helped me a lot. I will let you know once I am done.

Venkat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top