C#设置文件为可写
1.设置文件的读写权限,给NETWORK SERVICE配置读写权限
![](http://images0.cnblogs.com/blog/356287/201303/01111210-dcfeddc7126249d98818b48e911a3db7.jpg)
2.方法来自:http://msdn.microsoft.com/zh-cn/library/system.io.file.getattributes.aspx
public static void Update(string path) { //设置文件为可写 FileAttributes att = File.GetAttributes(path); if ((att & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) { att = RemoveAttribute(att, FileAttributes.ReadOnly); File.SetAttributes(path, att); } } private static FileAttributes RemoveAttribute(FileAttributes attributes, FileAttributes attributesToRemove) { return attributes & ~attributesToRemove; }