c# 怎么设置文件或文件夹的属性 和访问权限
if (!File.Exists(fullPath))
{
File.Create(fullPath);
}
以上代码为创建文件 ,怎么设置这个文件为只读.
求代码
[解决办法]
System.IO.File.SetAttributes
[解决办法]
File.SetAttributes(fullPath, FileAttributes.ReadOnly);
System.IO.FileInfo info=new System.IO.FileInfo(fullPath);
info.Attributes
[解决办法]
= System.IO.FileAttributes.ReadOnly;