c# 怎么设置文件或文件夹的属性 和访问权限

hsjyyzx 2013-06-13 03:24:03
if (!File.Exists(fullPath))
{
File.Create(fullPath);
}
以上代码为创建文件 ,怎么设置这个文件为只读.

求代码
...全文
143 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xky96 2013-06-13
  • 打赏
  • 举报
回复
            System.IO.FileInfo info=new System.IO.FileInfo(fullPath);
            info.Attributes |= System.IO.FileAttributes.ReadOnly;
charley007 2013-06-13
  • 打赏
  • 举报
回复
FileStream f = File.Create("path"); f.Close(); File.OpenRead("path");
coobai 2013-06-13
  • 打赏
  • 举报
回复
File.SetAttributes(fullPath, FileAttributes.ReadOnly);
bdmh 2013-06-13
  • 打赏
  • 举报
回复
System.IO.File.SetAttributes

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧