Пример #1
0
        public void SetReadOnly(string path, bool isReadOnly)
        {
            if (_sharpCifsFileSystem.IsEnabledForPath(path))
            {
                _sharpCifsFileSystem.SetReadOnly(path, isReadOnly);
                return;
            }

            var info = GetFileInfo(path);

            if (info.Exists && info.IsReadOnly != isReadOnly)
            {
                if (isReadOnly)
                {
                    File.SetAttributes(path, File.GetAttributes(path) | FileAttributes.ReadOnly);
                }
                else
                {
                    FileAttributes attributes = File.GetAttributes(path);
                    attributes = RemoveAttribute(attributes, FileAttributes.ReadOnly);
                    File.SetAttributes(path, attributes);
                }
            }
        }