如何使用C#将属性设置为文件夹 [英] How to set attributes to folder with C#

查看:60
本文介绍了如何使用C#将属性设置为文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮助我解决这个问题吗?我尝试使用DirectoryInfo将属性设置为文件夹.

Can anyone help me about this problem ? I have try DirectoryInfo to set attributes to folder.

DirectoryInfo dir=new DirectoryInfo(path)
dir.Attributes=File.Attributes.ReadOnly


但它仅适用于emty文件夹.我该怎么办? (对不起,我的英语不好)


But it work only with emty folder. How would i do ????
( Sorry for my bad english)

推荐答案

您必须像这样对它进行操作:

You have to OR it into it like this:

var di = new DirectoryInfo("SomeFolder");
di.Attributes |= FileAttributes.ReadOnly;



祝你好运!



Good luck!


这篇关于如何使用C#将属性设置为文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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