Click or drag to resize

PlaceholderFolderSetMetadata Method

IT Hit User File System
Updates placeholder folder information.

Namespace:  ITHit.FileSystem.Windows
Assembly:  ITHit.FileSystem.Windows (in ITHit.FileSystem.Windows.dll) Version: 3.3.9602.0
Syntax
public override void SetMetadata(
	IFileSystemItemMetadata folderMetadata
)

Parameters

folderMetadata
Type: ITHit.FileSystemIFileSystemItemMetadata
New placeholder folder information. This parameter must be of type IFolderMetadata.
Remarks

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

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