Mostrar encabezado o columna personalizados en el Explorador de Windows

My app adds some custom metadata to files. I want to display it in Windows Explorer like this:

Maqueta 1

o esto:

Maqueta 2

Is there a way to do this in .NET?

preguntado el 10 de marzo de 12 a las 16:03

Can I ask what approach you used to add custom metadata? Did you use an alternate data stream, or simply store the data in a hidden file, or something else? Thanks for any info! -

@amt528 I didn't end up pursuing the project. I tried a few things that might have worked but after 7 years don't really remember. -

I think it was something to do with NTFS file metadata. Copying to a different filesystem would nuke the metadata. -

Do you know if it gets nuked if you use the Windows Property System?… -

@amt528 I think it shouldn't get nuked but the best way to know that is to test it. Move the file with metadata to a flash drive formatted in FAT32 and then see if the metadata is present. I don't know where exactly the metadata is stored in this case. Maybe when you insert that flash drive on another computer, it won't have the metadata. -

2 Respuestas

There are two approaches to building custom columns in Windows File Manager: using Windows Property System and Property Definitions for Cloud Storage Provider. You will typically use the first approach to create custom properties for file types that you own. You will use the second approach when displaying custom data from your document management system or any other storage.

Using a Windows Property System.

Puede create custom properties for specific file types in Windows Vista and later versions. These properties can be read-only or read-write. As well as they can be indexed by Window Search indexer and participate in the search. There are some limitations: handlers cannot be implemented in managed code and should be implemented in C++.

  • The property is tied to the specific file type, which typically belongs to your application. You can not create a property for all file types.

Using Cloud Storage Provider Property Definitions

In Windows 10 Creators Update and later you can add custom columns for file systems created using API de Cloud Sync Engine (Storage Provider, Cloud Filter API). This API is used in such tools as OneDrive. You will need to register a Cloud Storage Provider sync root with custom properties definitions, provide data for your custom columns and finally implement a Cloud Storage provider using Cloud File/Cloud Filter API. enter image description here

Property definitions are not tied to a file type and can be added for all files. Also, even though only some API is available in .NET you still can call Win32 functions and build a cloud provider using managed code only.

Registering the Cloud Storage provider. Here is an example of the Storage Provider registration with custom columns in C#:

StorageProviderSyncRootInfo storageInfo = new StorageProviderSyncRootInfo();
storageInfo.Path = await StorageFolder.GetFolderFromPathAsync("C:\\Users\\User1\\VFS\\");
// Adds columns to Windows File Manager. 
// Show/hide columns in the "More..." context menu on the columns header.
var proDefinitions = storageInfo.StorageProviderItemPropertyDefinitions;
proDefinitions.Add(new StorageProviderItemPropertyDefinition { DisplayNameResource = "Lock Expires", Id = 2, });
proDefinitions.Add(new StorageProviderItemPropertyDefinition { DisplayNameResource = "Lock Scope", Id = 3, });

A complete registration example could be found aquí.

Providing data for property definitions. To provide the data for the columns you will use StorageProviderItemProperties.SetAsync() call:

IStorageItem storageItem = await Windows.Storage.StorageFile.GetFileFromPathAsync(path);
StorageProviderItemProperty propState = new StorageProviderItemProperty()
     Id = 3,
     Value = "Exclusive",
     IconResource = "C:\\path\\icon.ico" // The optional icon to be displayed in the Status column.
await StorageProviderItemProperties.SetAsync(storageItem, new StorageProviderItemProperty[] { propState });

Another approach would be implementing IStorageProviderItemPropertySource interface. It returns properties based on your file path.

Cloud Storage Provider implementation. Finally, you will need a complete file system implementation, supplying data for your files/folders placeholders. You can find complete examples in .NET/C# aquí:

contestado el 28 de mayo de 21 a las 10:05

When you say "file types you own", is this equivalent to saying the following field in this workflow: right click file > Properties > General tab > value field with pre text of "open with" and a "Change" button next to it? - MacGyver

@MacGyver. No, this means you can not create custom columns for .exe or .docx files. But you can create custom columns for your own custom file type, which is managed by your application. - Golpeó WebDAV

I think I found it, right click file > click "Properties" in right click menu > click "Security" tab > click "Advanced" button > see "Owner" field - MacGyver


It can be done on XP using a Column Handler shell extension - see here:

Sin embargo IColumnHandler is not supported on Vista and up. Here you have to implement PropertyHandler. See Windows SDK \Samples\winui\Shell\AppShellIntegration\PropertyHandlers.

Each property is described by property schema XML file. This property schema must be registered with PSRegisterPropertySchema(). Property handler implements IInitializeWithXXX, IPropertyStore y opcionalmente IPropertyStoreCapabilities. You have to register CLSID of your implementation for each file extension you want to handle.

Desafortunadamente, no puedes usar AllFileSystemObject or * in registration.

Respondido el 09 de junio de 21 a las 18:06

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.