how can I empty all files in a fold?

djwinter 2006-08-18 08:36:18
how can I empty all the files in a fold by C++/C ??
software will running on unix like system.
...全文
242 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
pacman2000 2006-08-18
  • 打赏
  • 举报
回复
system("/bin/rm -f /somedir/*");
djwinter 2006-08-18
  • 打赏
  • 举报
回复
to OpenHero(雨流星(^_^看风云)) :
that what I am trying to do, have not find a proper way to do this, I think c++ STL should offer this simple dir operation for us, but .......................
wish anyone may face this before and can help.
djwinter 2006-08-18
  • 打赏
  • 举报
回复
to: jiaowenhao
there is only config file in this fold, what I nead to do, is before recreate all the file, empty all the file first, avod the unexpected system error.
and can you let me know a little more detail about it?
OpenHero 2006-08-18
  • 打赏
  • 举报
回复
maybe 现在是没有找到c/C++自己封装的文件系统的API
djwinter 2006-08-18
  • 打赏
  • 举报
回复
so is that mean the onlyway can use is the system command? there is no way to complile the dir operation regardless the os?
jiaowenhao 2006-08-18
  • 打赏
  • 举报
回复
编一个递归函数,遍历本目录下的所有文件包括文件夹,在遍历的同时检测,如果是文件就删除
OpenHero 2006-08-18
  • 打赏
  • 举报
回复
你查找一下系统如何处理文件系统的API
遍历文件,删除文件,创建文件,文件操作是系统相关的操作
djwinter 2006-08-18
  • 打赏
  • 举报
回复
the thing is I have absolutely no idea how to use standard C++/C to complile this. can you give me a example to delete "c:/temp", and recreate it?
晨星 2006-08-18
  • 打赏
  • 举报
回复
Traverse the whole fold recursively, delete all each file and create a new empty one with the same name.
I think that will be OK.
OpenHero 2006-08-18
  • 打赏
  • 举报
回复
u can look up the apis find how to view all the files in the folder ,and do what u want!

65,186

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧