zoukankan
html css js c++ java
在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);
查看全文
相关阅读:
设计模式--17、建造者模式
设计模式--16、原型模式
面向对象的几大设计原则
设计模式--15、模板方法模式
设计模式--14、中介者模式
设计模式--13、享元模式
设计模式--12、外观模式
设计模式--11、命令模式
消息中间件ActiveMQ、RabbitMQ、RocketMQ、ZeroMQ、Kafka如何选型?
Kafka,Mq,Redis作为消息队列有何差异?
原文地址:https://www.cnblogs.com/kuku/p/81630.html
最新文章
python3连接Mongodb
手动爬虫之京东笔记本栏(ptyhon3)
手动爬虫之流程笔记1(python3)
python3连接外部Mysql
python中pip工具的安装与使用
在Editplus中Dev C++配置C++的编译运行环境
Python IDLE或shell中切换路径
idle命令行按ALT+P重复调出上个语句
MySQL 创建数据库
MySQL 连接
热门文章
MySQL 管理
MySQL 安装
PHP AJAX
PHP 数据库 ODBC
PHP MySQL 读取数据
PHP MySQL 预处理语句
PHP MySQL 插入多条数据
PHP MySQL 创建数据库
设计模式--19、解释器模式
设计模式--18、桥接模式
Copyright © 2011-2022 走看看