会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
kuku
学习笔记
博客园
首页
新随笔
联系
订阅
管理
在ASP.NET去掉文件的只读属性
我们可以使用 System.IO.File 类的 SetAttributes 方法为一个文件设置相关的属性,如:
//
为文件加上一个只读的属性
FileAttributes attrs
=
File.GetAttributes(
"
c:\\a.txt
"
);
File.SetAttributes(
"
c:\\a.txt
"
, attrs
|
FileAttributes.ReadOnly);
怎么把这个只读属性去掉呢?
//
先把文件的属性读取出来
FileAttributes attrs
=
File.GetAttributes(
"
c:\\a.txt
"
);
//
下面表达式中的 1 是 FileAttributes.ReadOnly 的值
// 此表达式是把 ReadOnly 所在的位改成 0,
attrs
=
(FileAttributes)((
int
)attrs
&
~
(
1
));
File.SetAttributes(
"
c:\\a.txt
"
, attrs);
posted @
2004-12-24 18:54
匡匡
阅读(
2886
) 评论(
3
)
收藏
举报
刷新页面
返回顶部
公告