Web Folder Sample

This sample is composed of two projects:

  • A self-sufficient ASP.NET MVC web server that exposes a custom REST/JSON API. The API looks like a "cloud drive" and exposes folders and items. Items have content, which can be downloaded or uploaded. This project is not strictly related to ShellBoost but is used for demonstration purposes.
  • This WPF application has a Shell folder that connects to the web server and exposes the "cloud drive" as Shell folders and Shell items.

This sample can be found in the GitHub repository with CBFS Shell samples.

Web Server Sample

The MVC web server API is synthesized using a portion of its controller code and corresponding URLs:

[Route("api/drive")] // get root folder
public Item Get()
 
[Route("api/drive/{id}")] // get an item from the hierarchy
public Item Get(Guid id) => Drive.Root.GetItem(id);
 
[Route("api/drive/{id}/children")] // get an item's children
public IEnumerable<Item> GetChildren(Guid id)
 
[Route("api/drive/{id}/folders")] // get an item's child folders
public IEnumerable<Item> GetFolders(Guid id)
 
[Route("api/drive/{id}/items")] // get an item's child items
public IEnumerable<Item> GetItems(Guid id)
 
[Route("api/drive/{id}/content")] // get an item's content
[HttpGet]
public IHttpActionResult Download(Guid id, string contentETag = null)
 
[Route("api/drive")] // modify an item
[HttpPost]
public IHttpActionResult Update([FromBody] Item value)
 
[Route("api/drive/{id}")] // upload an item's content
[HttpPut]
public async Task<IHttpActionResult> Upload(Guid id)
 
[Route("api/drive/{id}")] // delete an item
[HttpDelete]
public bool Delete(Guid id)

The web server has no UI: it is an API-only site. To demonstrate the sample, you must first run this web server project. By default, it runs on http://localhost:60311/.

When you run the WPF application (once you have started the web server project), you will see the following:


The first time you run it, click on "Register Proxy" to install the ShellBoost native proxy DLL and register it with the Shell. Then, "Open Extension's Location" should open a window on the "This PC" item. Next, you can navigate into the Samples.WebFolder virtual folder:


The folder hierarchy (test1/test2/TestN.txt, PNG, etc.) is hardcoded into the server for demonstration purposes.

All Shell items are virtual. You can see the server creates 10 text items and one dynamic PNG item. The name of the PNG matches the current (server) time. If you manually refresh the Explorer Window (F5), the time should change.

If you double click on the PNG file, you should see an image that was dynamically generated. Its content contains the time when it was generated on the server:


In this example, all items exist on the server, but we could have written a sample with an image generated locally as well.

Copyright (c) 2022 Callback Technologies, Inc. - All rights reserved.
CBFS Shell 2022 .NET Edition - Version 22.0 [Build 8367]