Click or drag to resize

PlaceholderFolderCreatePlaceholders Method

IT Hit User File System
Creates child placeholder files and folders.

Namespace:  ITHit.FileSystem.Windows
Assembly:  ITHit.FileSystem.Windows (in ITHit.FileSystem.Windows.dll) Version: 3.3.9602.0
Syntax
public uint CreatePlaceholders(
	IFileSystemItemMetadata[] children
)

Parameters

children
Type: ITHit.FileSystemIFileSystemItemMetadata
List of files and folders. Each item must implement either IFileMetadata or IFolderMetadata.

Return Value

Type: UInt32
Number of items created.
Exceptions
ExceptionCondition
ExistsExceptionThrown if any a file or folder with the name specified in the list exists.
Examples

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

C#
internal static async Task<uint> CreateAsync(string userFileSystemParentPath, FileSystemItemBasicInfo[] newItemsInfo)
{
    try
    {
        // Because of the on-demand population the file or folder placeholder may not exist in the user file system.
        // Here we also check that the folder content was loaded into user file system (the folder is not offline).
        if (Directory.Exists(userFileSystemParentPath)
            && !new DirectoryInfo(userFileSystemParentPath).Attributes.HasFlag(System.IO.FileAttributes.Offline))
        {
            // Create placeholders.
            uint created = new PlaceholderFolder(userFileSystemParentPath).CreatePlaceholders(newItemsInfo);

            // Create ETags.
            foreach (FileSystemItemBasicInfo child in newItemsInfo)
            {
                string userFileSystemItemPath = Path.Combine(userFileSystemParentPath, child.Name);
                await ETag.SetETagAsync(userFileSystemItemPath, child.ETag);
            }

            return created;
        }
    }
    catch (ExistsException ex)
        {
            // "Cannot create a file when that file already exists." 
            //await new UserFileSystemItem(userFileSystemParentPath).ShowDownloadErrorAsync(ex);

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

    return 0;
}
C#
internal static async Task<uint> CreateAsync(string userFileSystemParentPath, FileSystemItemBasicInfo[] newItemsInfo)
{
    try
    {
        // Because of the on-demand population the file or folder placeholder may not exist in the user file system.
        // Here we also check that the folder content was loaded into user file system (the folder is not offline).
        if (Directory.Exists(userFileSystemParentPath)
            && !new DirectoryInfo(userFileSystemParentPath).Attributes.HasFlag(System.IO.FileAttributes.Offline))
        {
            // Create placeholders.
            uint created = new PlaceholderFolder(userFileSystemParentPath).CreatePlaceholders(newItemsInfo);

            // Create ETags.
            foreach (FileSystemItemBasicInfo child in newItemsInfo)
            {
                string userFileSystemItemPath = Path.Combine(userFileSystemParentPath, child.Name);
                await ETag.SetETagAsync(userFileSystemItemPath, child.ETag);

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

            return created;
        }
    }
    catch (ExistsException ex)
        {
            // "Cannot create a file when that file already exists." 
            //await new UserFileSystemItem(userFileSystemParentPath).ShowDownloadErrorAsync(ex);

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

    return 0;
}
See Also