php 文件操作类
来源:互联网 发布:beat制作软件 编辑:程序博客网 时间:2024/06/08 10:00
<?php/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. *//** * Description of File * 文件操作类 * * @author admin */class File { //拷贝文件 public function copy_file($file, $copy_file) { if (file_exists($file) && file_exists($copy_file)) { return copy($file, $copy_file); } else { return false; } } //删除文件 public function delete_file($filename) { if (file_exists($filename)) { return unlink($filename); } else { return false; } } //重命名文件 public function rename_file($oldfilename, $newfilename) { if (file_exists($oldfilename) && file_exist($newfilename)) { return rename($oldfilename, $newfilename); } else { return false; } } //复制文件夹 public function copy_dir($olddir, $newdir) { if (!is_dir($olddir)) { throw new Exception("$oldir目录不存在"); return; } if (!is_dir($newdir)) { mkdir($newdir); } $hand = opendir($olddir); while ($file = readdir($hand)) { if (is_dir("$olddir/$file")) { if ($file != '.' && $file != '..') { $this->copy_dir($olddir . "/$file", $newdir . "/$file"); } } else { $this->copy_file($olddir . "/$file", $newdir . "/$file"); } } } //删除文件夹 public function delete_dir($dirname) { $hand = opendir($dirname); while ($file = readdir($hand)) { if ($file != '.' && $file != '..') { if(is_dir("$dirname/$file")){ $this->delete_dir("$dirname/$file"); }else{ $this->delete_file("$dirname/$file"); } } rmdir($dirname); } }}$file = new File();//$file->copy_dir("../01", "./04_copy");//$file->delect_file('index_new.php');//$file->delete_dir('./02_copy');$file->rmdirs('./03_copy');
0 0
- PHP文件操作类
- php文件操作类
- php 文件操作类
- php文件操作类
- php操作php文件
- 一个PHP文件操作的类
- PHP面向对象文件操作类
- php操作properties文件的类,只读
- PHP操作文件和文件夹类
- PHP ZIP扩展操作类文件
- PHP文件操作类(有所改动)
- 实用的php文件操作类
- php常用类之ftp文件操作
- 【php】目录操作 文件操作
- PHP操作文件问答
- PHP操作文件问答
- php文件操作
- PHP文件操作
- Unity 贝塞尔曲线
- mysql处理高并发,防止库存超卖
- iOS ---AFN--- 监测网络状态
- 出现 malformed or corrupted AST file: 'Unable to load module ".pcm": module file out of date'错误
- 【Android】 NFC课件
- php 文件操作类
- 连接池分析 pooling
- POJ 2436
- android----广播(BroadcastReceiver)的用法
- C# BackgroundWorker的使用
- 802.11n的HTC-MCS速率
- 给UIview加上xib
- 转一个 Xcode 7 缺少 *.dylib库的解决方法
- 密码学中的“盐值 Salt”