public SetExtendedAttribute ( string path, string key, string value, bool restoreLastModificationDate = false ) : void | ||
path | string | Path to the file or folder. |
key | string | Key of the extended attribute. |
value | string | Value of the extended attribute. |
restoreLastModificationDate | bool | If set to |
Résultat | void |
public void SetAttributeToFile() { 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)); }
public void SetExtendedAttributeDoesNotChangesModificationDate() { using (File.Create(path)); File.SetLastWriteTimeUtc(path, DateTime.UtcNow.AddDays(1)); DateTime futureDate = File.GetLastWriteTimeUtc(path); string key = "test"; string value = "value"; var reader = new ExtendedAttributeReaderUnix(); reader.SetExtendedAttribute(path, key, value, true); Assert.That(File.GetLastWriteTimeUtc(path), Is.EqualTo(futureDate)); }
public void SetExtendedAttributeOnNonExistingFileThrowsFileNotFoundException() { string key = "test"; var reader = new ExtendedAttributeReaderUnix(); Assert.Throws<FileNotFoundException>(() => reader.SetExtendedAttribute(path, key, null)); }
public void ListAttributesOfFolder() { Directory.CreateDirectory(path); string key = "test"; string value = "value"; var reader = new ExtendedAttributeReaderUnix(); Assert.That(reader.ListAttributeKeys(path).Count == 0); reader.SetExtendedAttribute(path, key, value); Assert.That(reader.ListAttributeKeys(path).Count == 1); Assert.Contains("test", reader.ListAttributeKeys(path)); }
public void RemoveAttributeFromFolder() { Directory.CreateDirectory(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); }
public void OverwriteAttributeOnFolder() { Directory.CreateDirectory(path); string key = "test"; string value = "value"; string value2 = "value2"; var reader = new ExtendedAttributeReaderUnix(); reader.SetExtendedAttribute(path, key, value); reader.SetExtendedAttribute(path, key, value2); Assert.That(reader.GetExtendedAttribute(path, key).Equals(value2)); }