Creating Virtual Drive v3


Custom Columns Registration

The above registration code will automatically add the Status column that contains file status icons. If you need to add more custom columns you will register them as part of the virtual file system registration:

var proDefinitions = storageInfo.StorageProviderItemPropertyDefinitions;
proDefinitions.Add(new StorageProviderItemPropertyDefinition { 
    DisplayNameResource = "Lock Owner", 
    Id = 2 });            
proDefinitions.Add(new StorageProviderItemPropertyDefinition { 
    DisplayNameResource = "Lock Scope", 
    Id = 4 });

Storing Custom Data on Windows Platform

On Windows, you can store custom data associated with a file or folder together with a file or folder. The IFileSystemItemMetadata interface provides the CustomData property which you can use to store up to 4KB of data. For example, you can store your remote storage file or folder ID in this property.

Typically you will set the custom data when listing the folder content, inside the  IFolder.GetChildrenAsync() method. But you can also set it at any other time by calling the PlaceholderItem.SetCustomData() method. Note that the custom data can be stored only with a placeholder item, it can not be stored with a regular file/folder. To detect if the item is a placeholder you can use the PlaceholderItem.IsPlaceholder() method.

string itemPath = @"C\Users\User1\VFS\";
    byte[] customData = Encoding.Unicode.GetBytes("<some item ID>");

To read the custom data you can use the PlaceholderItem.GetCustomData() method:

bytes[] customData = PlaceholderItem.GetItem(itemPath).GetCustomData();
string itemId = Encoding.Unicode.GetString(customData);

Note that some applications, for example, the Microsoft Office applications rename and then delete the original file during transactional save operation and all custom data will be deleted with it. See Creating Virtual Drive article for how to store custom data and avoid document deletion in your remote storage during Microsoft Office documents save operation.


Next Article:

Previous Versions