如何使用c#删除临时文件 [英] How do I delete temp files using c#

查看:347
本文介绍了如何使用c#删除临时文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在尝试删除临时文件和文件夹,我成功删除了临时文件夹的所有子文件夹,但是一个文件在删除时创建了与权限相关的问题。有没有办法删除该文件或跳过该文件?



请帮助,如果有人有想法。



提前致谢。

Hi
I am trying to delete temp files and folders, I got success in deleting all sub-folders of temp folder but one file creating permissions related problem in deletion. Is there any way to delete that file or skip that file??

Please help, if anyone having idea.

Thanks in advance.

推荐答案

创建现在无法删除的文件时,请使用FileOptions.DeleteOnClose选项。如果任何其他进程打开此文件,请参阅:[ ^ ]。
Use the FileOptions.DeleteOnClose option when creating the file you can't delete now. If any other processes open this file, see this: [^].


这必须是一个必须锁定的文件,因为它现在被使用了。

你不应该也不会能够删除它。
This must be a file that must be locked since it is getting used presently.
You should'nt and won't be able to delete it.


不要一次又一次地重新发布同一个问题。继续原始主题中的讨论。
Do NOT repost the same question again and again. Continue the discussion in your original thread.


这篇关于如何使用c#删除临时文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆