如何隐藏在C#中的文件? [英] How to hide file in C#?

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

问题描述

我想隐藏在C#中的文件。我知道文件的路径,并可以创建FileInfo对象。

I want to hide a file in c#. I know the file path and can create a FileInfo object.

如何隐藏呢?

推荐答案

接受的答案:

File.SetAttributes(path, FileAttributes.Hidden);

将导致它可能会丢失某些其他属性,所以你应该:

will result in certain other attributes it may have being lost, so you should:

File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.Hidden);

这篇关于如何隐藏在C#中的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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