删除目录
2015-07-31 16:45
260 查看
class del_path{
function wm_chief_delpath($del_path)
{
if(!file_exists($del_path))//目标目录不存在则建立
{
echo"Directory not found.";
return false;
}
$hand=@opendir($del_path);
$i=0;
while($file=@readdir($hand))
{
$i++;
if($file!="."&&$file!="..")
{
//目录
if(is_dir($del_path."/".$file))
{
$del_s_path=$del_path."/".$file;
$this->wm_chief_delpath($del_s_path);
}
else
{
$del_file=$del_path."/".$file;
$this->wm_chief_file($del_file);
}
}
}
@closedir($hand);
$this->wm_chief_path($del_path);
return true;
}
//删除文件
function wm_chief_file($del_file)
{
@unlink($del_file);
}
//删除目录
function wm_chief_path($del_path)
{
@rmdir($del_path);
}
}
function wm_chief_delpath($del_path)
{
if(!file_exists($del_path))//目标目录不存在则建立
{
echo"Directory not found.";
return false;
}
$hand=@opendir($del_path);
$i=0;
while($file=@readdir($hand))
{
$i++;
if($file!="."&&$file!="..")
{
//目录
if(is_dir($del_path."/".$file))
{
$del_s_path=$del_path."/".$file;
$this->wm_chief_delpath($del_s_path);
}
else
{
$del_file=$del_path."/".$file;
$this->wm_chief_file($del_file);
}
}
}
@closedir($hand);
$this->wm_chief_path($del_path);
return true;
}
//删除文件
function wm_chief_file($del_file)
{
@unlink($del_file);
}
//删除目录
function wm_chief_path($del_path)
{
@rmdir($del_path);
}
}
相关文章推荐
- 食物链(带权并查集)
- itoo3.1新开始,新起点......
- webView导入html5(滴滴打车)
- [LeetCode]238.Product of Array Except Self
- HTTP协议
- HTML总结
- Yii 集成 PHPExcel读取Excel文件
- DES3加密解密类
- OC之给NSString增加分类(分类的特点)
- hdu4003Find Metal Mineral 树形dp+分组背包
- mobile web开发 图片展示控件PhotoSwipe android手势放大功能
- python range()函数
- Atom飞行手册翻译: 2.5 查找和替换
- 将多个字符串高亮显示之TTTAttributedLabel
- 20150727 JavaScript入门学习笔记
- 关于iOS控件全局样式统一设定问题
- linux apache2 tomcat7 mod_jk 整合
- windows使用计划任务定时执行kettle资源库中的job
- iOS开发——Xcode基本操作
- Spinner(实现下拉列表)