Click or drag to resize

PlaceholderItemSetItemInfo Method

IT Hit User File System
Updates placeholder file or folder information. Automatically hydrates and dehydrates files.

Namespace:  ITHit.FileSystem.Windows
Assembly:  ITHit.FileSystem.Windows (in ITHit.FileSystem.Windows.dll) Version: 1.4.4298.0
Syntax
public abstract void SetItemInfo(
	IFileSystemItemBasicInfo fileSystemItemBasicInfo
)

Parameters

fileSystemItemBasicInfo
Type: ITHit.FileSystemIFileSystemItemBasicInfo
Placeholder folder or file information. Must be either of type IFileBasicInfo or IFolderBasicInfo.
Remarks

This method updates a file or folder placeholder attributes, creation and modification dates as well as custom data.

If this object represents a file, this method will also update file size and dehydrate the file. If the file is pinned or if the file is on disk and not marked as unpinned, it will then hydrate the file.

This method does not update the item name, the Name is ignored.

Examples

The code below is part of 'VirtualFileSystem' C# sample provided with the SDK.

C#
internal async Task<bool> UpdateAsync(FileSystemItemBasicInfo itemInfo)
{
    try
    {
        // Because of the on-demand population the file or folder placeholder may not exist in the user file system.
        if (FsPath.Exists(userFileSystemPath))
        {
            PlaceholderItem placeholderItem = PlaceholderItem.GetItem(userFileSystemPath);

            // Dehydrate/hydrate the file, update file size, custom data, creation date, modification date, attributes.
            placeholderItem.SetItemInfo(itemInfo);

            // Set ETag.
            await ETag.SetETagAsync(userFileSystemPath, itemInfo.ETag);

            // Clear icon.
            await ClearStateAsync();

            return true;
        }
    }
    catch (Exception ex)
    {
        await SetDownloadErrorStateAsync(ex);

        // Rethrow the exception preserving stack trace of the original exception.
        System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(ex).Throw();
    }
    return false;
}
C#
internal async Task<bool> UpdateAsync(FileSystemItemBasicInfo itemInfo)
{
    try
    {
        // Because of the on-demand population the file or folder placeholder may not exist in the user file system.
        if (FsPath.Exists(userFileSystemPath))
        {
            PlaceholderItem placeholderItem = PlaceholderItem.GetItem(userFileSystemPath);

            // To be able to update the item we need to remove the read-only attribute.
            if((FsPath.GetFileSystemItem(userFileSystemPath).Attributes | System.IO.FileAttributes.ReadOnly) != 0)
            {
                FsPath.GetFileSystemItem(userFileSystemPath).Attributes &= ~System.IO.FileAttributes.ReadOnly;
            }

            // Dehydrate/hydrate the file, update file size, custom data, creation date, modification date, attributes.
            placeholderItem.SetItemInfo(itemInfo);

            // Set ETag.
            await ETag.SetETagAsync(userFileSystemPath, itemInfo.ETag);

            // Clear icon.
            //await ClearStateAsync();

            // Set the lock icon and read-only attribute, to indicate that the item is locked by another user.
            await SetLockedByAnotherUserAsync(itemInfo.LockedByAnotherUser);

            return true;
        }
    }
    catch (Exception ex)
    {
        await SetDownloadErrorStateAsync(ex);

        // Rethrow the exception preserving stack trace of the original exception.
        System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(ex).Throw();
    }
    return false;
}
See Also