如何清除文件内容? [英] How can I clear the content of a file?

查看:147
本文介绍了如何清除文件内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次应用程序启动时,我都需要清除特定文件的内容。我该怎么办?

I need to clear the contents of a particular file every time the applications starts. How do I do it?

推荐答案

您可以使用 File.WriteAllText 方法。

System.IO.File.WriteAllText(@"Path/foo.bar",string.Empty);

这篇关于如何清除文件内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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