首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

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

2013-06-19 
c#怎么设置文件或文件夹的属性和访问权限 if (!File.Exists(fullPath)){File.Create(fullPath)}以上代码

c# 怎么设置文件或文件夹的属性 和访问权限
 if (!File.Exists(fullPath))
            {
                File.Create(fullPath);
            }
以上代码为创建文件  ,怎么设置这个文件为只读.

求代码
[解决办法]
System.IO.File.SetAttributes
[解决办法]

File.SetAttributes(fullPath, FileAttributes.ReadOnly);

[解决办法]
FileStream f = File.Create("path");
f.Close();
File.OpenRead("path");
[解决办法]
            System.IO.FileInfo info=new System.IO.FileInfo(fullPath);
            info.Attributes 
[解决办法]
= System.IO.FileAttributes.ReadOnly;

热点排行