CmisSync.Lib.Storage.FileSystem.ExtendedAttributeReaderUnix.RemoveExtendedAttribute C# (CSharp) Method

RemoveExtendedAttribute() public method

Removes the extended attribute.
public RemoveExtendedAttribute ( string path, string key ) : void
path string Removes attribute from this path.
key string Key of the attribute, which should be removed.
return void
        public void RemoveExtendedAttribute(string path, string key) {
            path = Path.GetFullPath(path);
            if (!File.Exists(path) && !Directory.Exists(path)) {
                throw new FileNotFoundException(string.Format("{0}: on path \"{1}\"", "No such file or directory", path), path);
            }

#if __MonoCS__
            long ret = Syscall.removexattr (path, prefix + key);
            if (ret != 0) {
#if! __COCOA__
                Errno errno = Syscall.GetLastError();
                if (errno != Errno.ENODATA) {
                    throw new ExtendedAttributeException(string.Format("{0}: on path \"{1}\"", errno.ToString(), path));
                }
#endif
            }
#else
            throw new WrongPlatformException();
#endif
        }

Usage Example

 public void RemoveAttributeFromFile()
 {
     using (File.Create(path));
     string key = "test";
     string value = "value";
     var reader = new ExtendedAttributeReaderUnix();
     reader.SetExtendedAttribute(path, key, value);
     Assert.That(reader.GetExtendedAttribute(path, key).Equals(value));
     reader.RemoveExtendedAttribute(path, key);
     Assert.That(reader.GetExtendedAttribute(path, key), Is.Null);
 }
All Usage Examples Of CmisSync.Lib.Storage.FileSystem.ExtendedAttributeReaderUnix::RemoveExtendedAttribute