-
Notifications
You must be signed in to change notification settings - Fork 0
StorageChangedEventArgs Class
Provides data for events that signal a change to a storage object, such as creation, modification, deletion, or relocation.
Namespace: Rheo.Storage
Assembly: Rheo.Storage.dll
public class StorageChangedEventArgs : EventArgsObject → EventArgs → StorageChangedEventArgs
| Constructor | Description |
|---|---|
| StorageChangedEventArgs(StorageChangeType, IStorageInformation) | Initializes a new instance with the specified change type and storage information. |
| Property | Type | Description |
|---|---|---|
| NewInfo | IStorageInformation | Gets the most recently retrieved storage information, or null if no information is available. |
| ChangeType | StorageChangeType | Gets the type of change that occurred to the storage object. |
Use this class with event handlers to determine which storage object was affected and the type of change that occurred. The NewInfo property contains the storage information for all change types except Deleted, where the storage object may no longer exist and only the change notification is available.
Initializes a new instance of the StorageChangedEventArgs class with the specified change type and storage information.
public StorageChangedEventArgs(
StorageChangeType changeType,
IStorageInformation? storageInformation
)changeType StorageChangeType
The type of change that occurred in the storage. Indicates whether the storage was created, modified, deleted, or relocated.
storageInformation IStorageInformation
The storage information associated with the change. Can be null only if the change type is Deleted.
Thrown if storageInformation is null and changeType is not Deleted.
Gets the most recently retrieved storage information, or null if no information is available.
public IStorageInformation? NewInfo { get; }The updated storage information after the change, or null for deletion events.
This property is null when ChangeType is Deleted, as the storage object no longer exists. For all other change types (Created, Modified, Relocated), this property contains the updated storage information.
Gets the type of change that occurred to the storage object.
public StorageChangeType ChangeType { get; }A value indicating whether the storage was created, deleted, modified, or relocated.
using Rheo.Storage;
using var file = new FileObject(@"C:\Documents\example.txt");
file.Changed += OnStorageChanged;
void OnStorageChanged(object? sender, StorageChangedEventArgs e)
{
switch (e.ChangeType)
{
case StorageChangeType.Created:
Console.WriteLine($"Created: {e.NewInfo?.AbsolutePath}");
break;
case StorageChangeType.Modified:
Console.WriteLine($"Modified: {e.NewInfo?.AbsolutePath}");
Console.WriteLine($"New size: {e.NewInfo?.Size} bytes");
break;
case StorageChangeType.Relocated:
Console.WriteLine($"Relocated to: {e.NewInfo?.AbsolutePath}");
break;
case StorageChangeType.Deleted:
Console.WriteLine("Storage object was deleted");
// NewInfo is null for deletions
break;
}
}
// Trigger events
file.Write(new byte[] { 1, 2, 3 }); // Modified
file.Rename("renamed.txt"); // Relocated
file.Delete(); // Deletedusing Rheo.Storage;
using var dir = new DirectoryObject(@"C:\Projects");
dir.Changed += (sender, e) =>
{
if (e.ChangeType == StorageChangeType.Modified && e.NewInfo != null)
{
var dirInfo = (DirectoryInformation)e.NewInfo;
Console.WriteLine($"Directory updated:");
Console.WriteLine($" Files: {dirInfo.NoOfFiles}");
Console.WriteLine($" Directories: {dirInfo.NoOfDirectories}");
Console.WriteLine($" Size: {dirInfo.FormattedSize}");
}
};Specifies the type of change that occurred to a storage object.
Namespace: Rheo.Storage
Assembly: Rheo.Storage.dll
public enum StorageChangeType| Field | Value | Description |
|---|---|---|
| Created | 0 | The storage object was created. |
| Deleted | 1 | The storage object was deleted. |
| Modified | 2 | The storage object was modified. |
| Relocated | 3 | The storage object was moved or renamed. |
This enumeration is used with StorageChangedEventArgs to indicate what type of change occurred to a storage object. The Relocated type covers both move and rename operations, as both result in a change to the object's path.
using Rheo.Storage;
using var file = new FileObject(@"C:\Documents\log.txt");
file.Changed += (sender, e) =>
{
// Only process modifications, ignore relocations
if (e.ChangeType == StorageChangeType.Modified)
{
Console.WriteLine("File content was modified");
ProcessFileUpdate(e.NewInfo);
}
};
void ProcessFileUpdate(IStorageInformation? info)
{
if (info != null)
{
Console.WriteLine($"New size: {info.Size} bytes");
Console.WriteLine($"Modified: {info.LastWriteTime}");
}
}bool HandleStorageChange(StorageChangeType changeType, IStorageInformation? info)
{
return changeType switch
{
StorageChangeType.Created => HandleCreation(info),
StorageChangeType.Modified => HandleModification(info),
StorageChangeType.Relocated => HandleRelocation(info),
StorageChangeType.Deleted => HandleDeletion(),
_ => false
};
}-
Storage Objects
-
Storage Information
-
Platform-Specific
-
Content-Type Analysis
-
Results
-
Models
-
-
Events & Progress