我想把某个文件夹中的文件全部删除,该用什么控件或函数
我想把某个文件夹中的文件全部删除,该用什么控件或函数 问题点数:0、回复次数:3Top
1 楼chobits(凯凯)回复于 2004-05-04 15:59:03 得分 0
up~~~~~~~~~~~~~~Top
2 楼weixing979(★★★闪电侠★★★)回复于 2004-05-04 16:03:07 得分 0
RemoveDir 删除空目录
DeleteFile 删除文件Top
3 楼matq2008(叶子.net)回复于 2004-05-04 16:09:50 得分 0
从chinabcb看到的
*------------------------------------------------------------------------
* Del the first Directory( whose name is all digital )
* in the path your give!
------------------------------------------------------------------------*/
bool lxq_lib::DelFirstDigitalDir( AnsiString& FilePath )
{
if ( FilePath.IsEmpty() || FilePath.Length() < 4 )
{
return false ;
}
if ( FilePath.SubString(FilePath.Length(),1) != "\\" )
{
FilePath += "\\" ;
}
AnsiString FileAll = FilePath + "*.*" ;
WIN32_FIND_DATA fd ;
HANDLE handle = FindFirstFile( FileAll.c_str(), &fd ) ;
if ( handle != INVALID_HANDLE_VALUE )
{
do
{
if ( String(fd.cFileName) == "." || String(fd.cFileName) == ".." )
{
continue ;
}
if ( fd.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY )
{
try
{
StrToInt(fd.cFileName) ;
lxq_lib::DeleteDirectoryEx( FilePath + fd.cFileName ) ;
}
catch(...)
{
continue ;
}
}
}
while ( FindNextFile( handle, &fd ) ) ;
FindClose(handle) ;
return true ;
}
return true ;
}
Top




