private static void UpdateStandardInformation(DirectoryEntry dirEntry, File file, StandardInformationModifier modifier) { // Update the standard information attribute - so it reflects the actual file state NtfsStream stream = file.GetStream(AttributeType.StandardInformation, null); StandardInformation si = stream.GetContent<StandardInformation>(); modifier(si); stream.SetContent(si); // Update the directory entry used to open the file, so it's accurate dirEntry.UpdateFrom(file); // Write attribute changes back to the Master File Table file.UpdateRecordInMft(); }
private void UpdateStandardInformation(string path, StandardInformationModifier modifier) { DirectoryEntry dirEntry = GetDirectoryEntry(path); if (dirEntry == null) { throw new FileNotFoundException("File not found", path); } else { File file = GetFile(dirEntry.Reference); UpdateStandardInformation(dirEntry, file, modifier); } }
private void UpdateStandardInformation(string path, StandardInformationModifier modifier) { DirectoryEntry dirEntry = GetDirectoryEntry(path); if (dirEntry == null) { throw new FileNotFoundException("File not found", path); } else { File file = GetFile(dirEntry.Reference); // Update the standard information attribute - so it reflects the actual file state NtfsStream stream = file.GetStream(AttributeType.StandardInformation, null); StandardInformation si = stream.GetContent<StandardInformation>(); modifier(si); stream.SetContent(si); // Update the directory entry used to open the file, so it's accurate dirEntry.UpdateFrom(file); // Write attribute changes back to the Master File Table file.UpdateRecordInMft(); } }