Skip to content

WindowsStorageInfo Struct

Naveen Dharmathunga edited this page Jan 19, 2026 · 1 revision

WindowsStorageInfo Struct

Represents detailed information about a file or directory on a Windows file system.

Namespace: Rheo.Storage.Information

Assembly: Rheo.Storage.dll

Definition

public struct WindowsStorageInfo : IStorageInfoStruct

Implements

  • IStorageInfoStruct

Properties

Property Type Description
Attributes FileAttributes Gets or sets the file attributes.
Size UInt64 Gets or sets the size in bytes.
CreationTime DateTime Gets or sets the creation time.
LastWriteTime DateTime Gets or sets the last write time.
LastAccessTime DateTime Gets or sets the last access time.
DisplayName String Gets or sets the display name for the file as provided by Windows Shell.
TypeName String Gets or sets the type name (e.g., "Text Document") as provided by Windows Shell.
Icon Icon Gets or sets the handle to the icon representing this file.
OwnerSid String Gets or sets the security identifier (SID) of the file owner.
HardLinkCount UInt32 Gets or sets the number of hard links to the file.
VolumeSerialNumber UInt32 Gets or sets the volume serial number of the volume containing the file.
FileIndex UInt64 Gets or sets the file index (unique identifier on the volume).
ReparseTarget String Gets or sets the target path if the file is a reparse point.

Remarks

This structure provides comprehensive file metadata obtained directly from Windows APIs, including attributes, size, timestamps, security information, and Shell-provided display information. Icon handles returned in this structure must be destroyed using DestroyIcon when no longer needed.

This struct is typically used internally by the storage information system and is not directly instantiated by user code.


Property Details

Attributes

Gets or sets the file attributes.

public FileAttributes Attributes { get; set; }

Property Value

FileAttributes

The file attributes flags.


Size

Gets or sets the size in bytes.

public ulong Size { get; set; }

Property Value

UInt64

The file size in bytes.


CreationTime

Gets or sets the creation time.

public DateTime CreationTime { get; set; }

Property Value

DateTime

The creation timestamp.


LastWriteTime

Gets or sets the last write time.

public DateTime LastWriteTime { get; set; }

Property Value

DateTime

The last write timestamp.


LastAccessTime

Gets or sets the last access time.

public DateTime LastAccessTime { get; set; }

Property Value

DateTime

The last access timestamp.


DisplayName

Gets or sets the display name for the file as provided by Windows Shell.

public string DisplayName { get; set; }

Property Value

String

The user-friendly display name.

Remarks

This name is provided by the Windows Shell and may differ from the actual file name for special system files or shortcuts.


TypeName

Gets or sets the type name as provided by Windows Shell.

public string TypeName { get; set; }

Property Value

String

The file type description (e.g., "Text Document", "PNG Image").

Remarks

This is the same type name displayed in Windows Explorer's "Type" column.


Icon

Gets or sets the handle to the icon representing this file.

public Icon Icon { get; set; }

Property Value

Icon

The icon handle.

Remarks

The icon handle must be destroyed with DestroyIcon when no longer needed to prevent resource leaks.


OwnerSid

Gets or sets the security identifier (SID) of the file owner.

public string? OwnerSid { get; set; }

Property Value

String

The owner's SID, or null if not available.


HardLinkCount

Gets or sets the number of hard links to the file.

public uint HardLinkCount { get; set; }

Property Value

UInt32

The count of hard links.

Remarks

A value greater than 1 indicates the file has multiple hard links pointing to it.


VolumeSerialNumber

Gets or sets the volume serial number of the volume containing the file.

public uint VolumeSerialNumber { get; set; }

Property Value

UInt32

The volume serial number.


FileIndex

Gets or sets the file index (unique identifier on the volume).

public ulong FileIndex { get; set; }

Property Value

UInt64

The unique file identifier on the volume.

Remarks

This value, combined with the volume serial number, uniquely identifies the file on the system.


ReparseTarget

Gets or sets the target path if the file is a reparse point.

public string? ReparseTarget { get; set; }

Property Value

String

The target path for symbolic links, junctions, or other reparse points, or null if not a reparse point.


Examples

Accessing Windows-Specific Information

The following example demonstrates accessing Windows-specific storage details:

using Rheo.Storage.Information;

var fileInfo = new FileInformation(@"C:\Documents\file.txt");

if (fileInfo.TryGetWindowsStorageInfo(out var winInfo))
{
    Console.WriteLine($"Display Name: {winInfo.DisplayName}");
    Console.WriteLine($"Type Name: {winInfo.TypeName}");
    Console.WriteLine($"Owner SID: {winInfo.OwnerSid}");
    Console.WriteLine($"Hard Links: {winInfo.HardLinkCount}");
    Console.WriteLine($"Volume Serial: {winInfo.VolumeSerialNumber:X8}");
    Console.WriteLine($"File Index: {winInfo.FileIndex:X16}");
    
    if (winInfo.Icon != null)
    {
        Console.WriteLine($"Icon available: {winInfo.Icon.Width}x{winInfo.Icon.Height}");
    }
}

Checking for Reparse Points

The following example shows how to check for symbolic links and junctions:

using Rheo.Storage.Information;

var fileInfo = new FileInformation(@"C:\Links\shortcut");

if (fileInfo.TryGetWindowsStorageInfo(out var winInfo) && 
    winInfo.ReparseTarget != null)
{
    Console.WriteLine($"This is a reparse point");
    Console.WriteLine($"Target: {winInfo.ReparseTarget}");
}

Thread Safety

This struct is not thread-safe. Instances should not be modified from multiple threads simultaneously.

See Also

Clone this wiki locally