急求删除目录及目录上的所有文件 wince

急!求删除目录及目录下的所有文件 wince
大家好!我想了各种办法想删除目录下的所有文件,怎么都不成功,网上的两种办法都试过了

一、包含了头文件#include "shellapi.h"
BOOL CsystemDlg::DelTree(LPCTSTR lpszPath)
{
  SHFILEOPSTRUCT FileOp;
  FileOp.fFlags = FOF_NOCONFIRMATION;
  FileOp.hNameMappings = NULL;
  FileOp.hwnd = NULL;
  FileOp.lpszProgressTitle = NULL;
  FileOp.pFrom = lpszPath;
  FileOp.pTo = NULL;
  FileOp.wFunc = FO_DELETE;


  return ::SHFileOperationW(&FileOp)==0;
}

运行结果:
无法解析的外部符号 SHFileOperationW,该符号在函数 "public: int __cdecl CsystemDlg::DelTree(wchar_t const *)" (?DelTree@CsystemDlg@@QAAHPB_W@Z) 中被引用

二、

CString strDir = L"\\NandFlash\\2";
if(strDir.IsEmpty())  
{  
  RemoveDirectory(strDir);  
  return;  
}  
// 首先删除文件及子文件夹  
CFileFind ff;  
BOOL bFound = ff.FindFile(strDir+"\\*",0);  
while(bFound)  
{  
  bFound = ff.FindNextFile();  
  if(ff.GetFileName()=="."||ff.GetFileName()=="..")  
  continue;  
  // 去掉文件(夹)只读等属性  
  SetFileAttributes(ff.GetFilePath(), FILE_ATTRIBUTE_NORMAL);  
  if(ff.IsDirectory())  
  {  
  // 递归删除子文件夹  
DeleteDirectory(ff.GetFilePath());  
RemoveDirectory(ff.GetFilePath());  
  }  
  else 
  {  
DeleteFile(ff.GetFilePath()); // 删除文件  
  }  
}  
ff.Close();  
// 然后删除该文件夹  
RemoveDirectory(strDir);  

}



运行结果:
1>.\systemDlg.cpp(1838) : error C2065: 'CFileFind' : undeclared identifier

------解决方案--------------------
#include "direct.h"

void DeleteDirFile(char *pchPath)
{
WIN32_FIND_DATA stData;

char chFile[_MAX_DIR] = _T("");
sprintf_s(chFile, sizeof(chFile), "%s%s", pchPath, "*.*");

HANDLE hFind = ::FindFirstFile(chFile, &stData);

if (hFind != INVALID_HANDLE_VALUE)
{
while (::FindNextFile(hFind,&stData))
{
char chName[_MAX_FNAME] = _T("");

//判断是否为目录
if (stData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
strcpy_s(chName, sizeof(chName), stData.cFileName);

//判断是否为.和..
if (strcmp(chName, ".") != 0 && strcmp(chName, "..") != 0)
{
//如果是真正的目录,进行递归
char chChildPath[_MAX_DIR] = _T("");
sprintf_s(chChildPath, sizeof(chChildPath), "%s%s\\", pchPath, stData.cFileName);
DeleteDirFile(chChildPath);
}
}
else
{
sprintf_s(chFile, sizeof(chFile), "%s%s", pchPath, stData.cFileName);

DeleteFile(chFile);
}
}
::FindClose(hFind);
}

RemoveDirectory(pchPath);
}
------解决方案--------------------
http://topic.****.net/t/20010325/08/88620.html
------解决方案--------------------
关于问题二:
wince 下目前不支持 CFileFind 类操作。
可以用 ::FindFirstFile(),::FindNextFile()以及Delete()函数。
------解决方案--------------------
问题一:
我也有这样的问题,刚解决。

在你的工程中包含了头文件#include "shellapi.h" ,

这时还缺少库(ceShell),再加一句:

#pragma comment (lib,"Ceshell.lib")