|
-
May 13th, 1999, 09:43 PM
#1
FindFirstFile() Function??
Can anyone help me correct this code or maybe suggest something better?
I am attempting to delete all the files in a directory that have the "xqc" extension. I am getting an Access Violation in the NT.dll dll when it gets to the FindFirstFile() function. What is wrong with this code?
In addition, I am trying to delete only files that I can delete, so I want to avoid deleting read-only files and/or directories that are returned by the FindFirstFile() function.
Please note that some lines are commented out.
Thanks for your help,
Austin.
---------------------------------------------------------------
bool CUpdtDlg: eleteWQRFiles(CString delPath)
{
HANDLE fileHnd;
LPWIN32_FIND_DATA lpFileData = 0;
LPCTSTR pDelFile;
CString delFile;
bool result = false;
delFile = delPath + "*.xqc";
pDelFile = delFile.GetBuffer(delFile.GetLength() + 1);
delFile.ReleaseBuffer(-1);
fileHnd = FindFirstFile(pDelFile, lpFileData);
// fileHnd = FindFirstFile("c:\\data\\cordraw\\ixf\\*.xqc", lpFileData);
if (fileHnd != INVALID_HANDLE_VALUE)
{
// if (lpFindFileData.dwFileAttributes
// FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_READONLY )
DeleteFile(LPCTSTR (delPath + lpFileData->cFileName));
while (FindNextFile(fileHnd, lpFileData))
{
DeleteFile(LPCTSTR (delPath + lpFileData->cFileName));
}
}
FindClose(fileHnd);
return result;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|