ruby 删除文件夹(包括文件夹中的文件夹和文件)
2024-10-11 16:29:04
def deleteDirectory(dirPath)
if File.directory?(dirPath)
puts "是文件夹";
Dir.foreach(dirPath) do |subFile|
if subFile != '.' and subFile != '..'
deleteDirectory(File.join(dirPath, subFile));
end
end
Dir.rmdir(dirPath);
else
File.delete(dirPath);
end
end
puts "删除完毕"
deleteDirectory(File.join(Dir.getwd, 'uexBrokenLine'));
最新文章
- python3的基础练习题
- Unity 碰撞器
- 【HDU 5855】Less Time, More profit(网络流、最小割、最大权闭合子图)
- Effective C++ -----条款53:不要轻忽编译期的警告
- struts.xml配置
- EF 之 MVC 排序,查询,分页 Sorting, Filtering, and Paging For MVC About EF
- Linux操作系统备份之一:使用LVM快照实现Linux操作系统数据的在线备份
- 【转】Haproxy安装及配置
- NeHe OpenGL教程 第二十四课:扩展
- easyui 页签
- Contest20140705 testB DP
- 屏幕录制:SCR Screen Recorder Pro v0.14.3汉化破解版
- Linux 终端部分重要快捷键
- MVC:Controller向View传值方式总结
- UVALive 4992 Jungle Outpost(半平面交)
- APP测试中iOS和Android的区别
- Flask —— 信号(5)
- SpringBoot使用AOP
- io流和序列化
- [py]类的专有方法
热门文章
- CentOS7 编译安装LNMP
- 训练赛 Grouping(强连通分量缩点 + DAG求最长路)
- codeforece Round#311 BCDE
- 【Web优化】Yslow优化法则(四)启用Gzip压缩
- SQL注入问题
- Oracle SQL Lesson (9) - 操作数据(增删改)
- C++ Primer高速学习 第一章 获得二:输入和输出 (IO)
- 【leetcode】LRU
- 分析java.lang.NullPointerException thrown in RelativeLayout measure()
- Windows Phone 8 - Runtime Location API - 2