C#: Create a virtual drive in Computer
Asked Answered
V

4

36

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) {
    ShowFilesFromAmazon();
}

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.

Vassili answered 11/9, 2008 at 15:35 Comment(0)
D
7

You can use the Dokan library to create a virtual drive. There is a .Net wrapper for interfacing with C#.

Dachi answered 11/9, 2008 at 16:48 Comment(3)
As far as I know there is no way to use it in a commercial project, it is under LGPL license. I would suggest using WebDAV server + built-in Windows/Mac OS X drive mounting functionality. Probably this is the fastest way to achieve the result.Cheder
I think you mix things: LGPL is not incompatible with a commercial usage. You can link against the dll (reference it) and only if you make changes to the Dokan dll itself you must release the source: but the source of the modified Dokan library ONLY! THIS IS NOT THE CASE FOR GPL CODE, FOR GPL YOU MUST RELEASE THE SOURCE OF YOUR WHOLE APPLICATION.Atingle
Dokan is long dead and buggy with no hope for bug fixes.Goren
T
18

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 synced 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, etc. The documentation says it is intended for “projecting” hierarchical data in the form of file system.

Timbre answered 18/3, 2021 at 18:12 Comment(0)
D
7

You can use the Dokan library to create a virtual drive. There is a .Net wrapper for interfacing with C#.

Dachi answered 11/9, 2008 at 16:48 Comment(3)
As far as I know there is no way to use it in a commercial project, it is under LGPL license. I would suggest using WebDAV server + built-in Windows/Mac OS X drive mounting functionality. Probably this is the fastest way to achieve the result.Cheder
I think you mix things: LGPL is not incompatible with a commercial usage. You can link against the dll (reference it) and only if you make changes to the Dokan dll itself you must release the source: but the source of the modified Dokan library ONLY! THIS IS NOT THE CASE FOR GPL CODE, FOR GPL YOU MUST RELEASE THE SOURCE OF YOUR WHOLE APPLICATION.Atingle
Dokan is long dead and buggy with no hope for bug fixes.Goren
A
2

Yes, use the classes in System.IO.IsolatedStorage

Abroad answered 11/9, 2008 at 15:37 Comment(1)
I don't understand how IsloatedStorage can add an OnRead event and do ShowFilesFromAmazon()? Could you give me an example? Thanks!Monmouth
S
2

The contents of My Computer can include Shell Namespace Extensions. These COM objects run inside the main Explorer process, as do many other shell extensions. Using C# for such extensions is a bad idea, since your extension cannot control which CLR version Explorer.exe can use. And Microsoft allows only one CLR per process.

Sclerosis answered 6/11, 2008 at 14:46 Comment(1)
I think this changed with .net 4.0Sohn

© 2022 - 2024 — McMap. All rights reserved.