如何删除文件夹下所有的文件(包括非空目录和文件)????

如何删除文件夹下所有的文件(包括非空目录和文件)????

gxd791127 ( 一级用户 该版得分小于等于100分    2005-03-28 09:15:47 在  C++ Builder /  基础类 提问

最近遇到个问题,要删除某个文件夹下所有的文件,该文件夹下包括非空目录和一些文件,而使用DeleteFile只能删除一个指定名称的文件,哪位大侠能帮帮忙给解决一下。小弟在这里谢谢了!!!!!
问题点数: 50、回复次数: 11
3楼  songhtao   ( 三十年孤独) 三星用户 该版得分小于等于50000分,大于30000分  回复于  2005-03-28 09:48:46  得分 0

Deletes   a   subfolder   from   the   given   folder.  
   
  Syntax  
   
  HRESULT   DeleteFolder(ULONG   cbEntryID,   LPENTRYID   lpEntryID,   ULONG   ulUIParam,   LPMAPIPROGRESS   lpProgress,   ULONG   ulFlags)  
   
  Parameters  
   
  cbEntryID  
   
  Input   parameter   containing   the   number   of   bytes   in   the   entry   identifier   pointed   to   by   the   lpEntryID   parameter.    
   
  lpEntryID  
   
  Input   parameter   pointing   to   the   entry   identifier   of   the   folder   to   delete.  
   
  ulUIParam  
   
  Input   parameter   containing   the   handle   of   the   window   the   dialog   box   is   modal   to.   The   ulUIParam   parameter   is   ignored   unless   the   FOLDER_DIALOG   flag   is   set   in   the   ulFlags   parameter   and   NULL   is   passed   in   the   lpProgress   parameter.  
   
  lpProgress  
   
  Input   parameter   pointing   to   a   progress   object   that   contains   client-supplied   progress   information.   If   NULL   is   passed   in   the   lpProgress   parameter,   the   progress   information   is   provided   by   MAPI.   The   lpProgress   parameter   is   ignored   unless   the   FOLDER_DIALOG   flag   is   set   in   the   ulFlags   parameter.  
   
  ulFlags  
   
  Input   parameter   containing   a   bitmask   of   flags   used   to   control   the   deletion   of   the   folders.   The   following   flags   can   be   set:  
   
  DEL_FOLDERS  
   
  Deletes   all   subfolders   of   the   subfolder   indicated   in   the   lpEntryID   parameter.    
   
  DEL_MESSAGES  
   
  Deletes   all   messages   in   the   folder   indicated   in   the   lpEntryID   parameter.  
   
  FOLDER_DIALOG  
   
  Displays   a   progress-information   user   interface   while   the   operation   proceeds.  
   
  Return   Values  
   
  S_OK  
   
  The   call   succeeded   and   has   returned   the   expected   value   or   values.  
   
  MAPI_E_HAS_FOLDERS  
   
  The   folder   being   deleted   contains   folders   and   the   DEL_FOLDERS   flag   was   not   set.   The   folder   was   not   deleted.  
   
  MAPI_E_HAS_MESSAGES  
   
  The   folder   being   deleted   contains   messages   and   the   DEL_MESSAGES   flag   was   not   set.   The   folder   containing   the   messages   was   not   deleted.  
   
  MAPI_W_PARTIAL_COMPLETION  
   
  The   call   succeeded,   but   not   all   of   the   entries   were   successfully   deleted.   Use   the   HR_FAILED   macro   to   test   for   this   warning,   though   the   call   should   be   handled   as   a   successful   return.  
   
  Comments  
   
  Message   store   providers   use   the   IMAPIFolder::DeleteFolder   method   to   delete   a   subfolder   of   a   folder.   If   the   message   store   provider   so   indicates,   DeleteFolder   can   also   delete   all   messages   or   all   subfolders   in   a   subfolder,   or   both.   To   delete   all   messages   in   a   subfolder,   the   client   application   sets   the   DEL_MESSAGES   flag   in   the   ulFlags   parameter;   to   delete   all   subfolders   in   a   subfolder,   the   client   application   sets   the   DEL_FOLDERS   flag   in   ulFlags.   However,   no   flag   need   be   set   to   delete   any   associated   items,   such   as   views   or   form   definitions,   from   a   folder.  
   
  To   allow   deletions   of   more   than   one   subfolder   to   continue   even   if   one   or   more   subfolders   marked   for   deletion   by   the   calling   application   do   not   exist   or   have   been   moved   elsewhere,   and   thus   cannot   be   deleted,   a   message   store   provider   should   attempt   to   complete   the   deletion   as   best   it   can   for   each   subfolder   specified.   The   provider   should   stop   the   deletion   without   completing   it   only   in   the   case   of   failures   it   cannot   control,   such   as   running   out   of   memory   or   disk   space,   message   store   corruption,   and   so   on.  
   
  If   DeleteFolder   successfully   deletes   every   folder   marked   for   deletion,   it   returns   the   value   S_OK.   If   one   or   more   folders   cannot   be   deleted,   DeleteFolder   returns   the   value   MAPI_W_PARTIAL_COMPLETION   or   MAPI_E_NOT_FOUND,   depending   on   the   message   store's   implementation.   If   DeleteFolder   returns   a   different   value,   such   as   MAPI_E_NOT_ENOUGH_MEMORY,   that   indicates   the   call   did   not   complete;   it   might   have   already   deleted   one   or   more   folders   or   messages   without   being   able   to   continue.   The   calling   application   cannot   proceed   on   the   assumption   that   an   error   return   implies   no   work   was   done.  
   
  During   a   DeleteFolder   call,   messages   that   are   being   processed   by   the   MAPI   spooler   are   not   deleted,   nor   does   the   message   store   provider   attempt   to   call   the   IMsgStore::AbortSubmit   method   on   such   messages.   A   message   being   processed   by   the   MAPI   spooler   is   left   in   the   folder   in   which   it   resides.   This   functionality   might   prevent   one   or   more   folders   from   being   deleted   because   they   still   have   contents.
Top
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值