C#: Create a virtual drive in Computer


Is there any way to create a virtual drive in "(My) Computer" and manipulate it, somewhat like JungleDisk does it?

It probably does something like:

override OnRead(object sender, Event e) {

Are there any API:s for this? Maybe to write to an XML-file or a database, instead of a real drive.

The Dokan Library seems to be the answer that mostly corresponds with my question, even though System.IO.IsolatedStorage seems to be the most standardized and most Microsoft-environment adapted.

Best Solution

Depending on what type of virtual drive you wish to build, here are some new OS API recently introduced in Windows, macOS and iOS.

Some of the below API is available as managed .NET code on Windows but many are a native Windows / macOS / iOS API. Even though, I was able to consume many of the below API in .NET and Xamarin applications and build entire Virtual Drive in C# for Windows, macOS and iOS.

For Remote Cloud Storage

On Windows. Windows 10 provides Cloud Sync Engine API for creating virtual drives that publish data from a remote location. It is also known under the “Cloud Filter API” name or “Windows Cloud Provider”. Here are its major features:

  • On-demand folders listing. Folder listing is made only when the first requested by the client application to the file system is made. File content is not downloaded, but all file properties including file size are available on the client via regular files API.
  • On-demand file content loading. File content can be downloaded in several modes (progressive, streaming mode, allow background download, etc) and made available to OS when application makes first file content reading request.
  • Offline files support. Files can be edited in the offline mode, pinned/unpinned and synched to/from the server.
  • Windows shell integration. Windows File Manager shows file status (modified, in-sync, conflict) and file download progress.
  • Metadata and properties support. Custom columns can be displayed in Windows File Manager as well as some binary metadata can be associated with each file and folder.

On macOS and iOS. MacOS Big Sur and iOS 11+ provides similar API called File Provider API. Its features are similar to what Windows API provides:

  • On-demand folders listing.
  • On-demand files content loading.
  • Offline files support.
  • File Manager Integration. In macOS Finder and iOS Files application you can can show file status (in the cloud, local).

I am not sure currently if files/folders and can show custom columns in macOS Finder and store any metadata.

For High-Speed Local Storage

On Windows. Windows provides ProjFS API. Its main difference from the Cloud Sync Engine API and macOS/iOS File Provider API is that it hides the fact that it is a remote storage. It does not provide any indication of the file status, download progress, ets. The documentation says it is intended for “projecting” hierarchical data in the form of file system.