Virtual drives in .NET?
Is there any easy library for .NET to mount virtual drives?
I need to mount an archive in a virtua开发者_JAVA技巧l drive and, most likely, use a virtual file system. The archive format does not support folders so I'd need to supply the files and folders manually from the archive. Attributes aren't supported as well but I use metadata files to store them. The more control over the drive and FS I have, the better.Windows 10 provides cloud filter API and projected file system API. Both run in user mode, do not require signing and driver installation. The cloud filter API is part of Windows for a couple of years already.
Example in .NET on GitHub.
You can use the Dokan library to create a virtual drive. Take a look at Issue 43: Wont install on Windows 7
If you need to do this in code, you can use our Callback File System -- this product was designed for tasks like yours in mind. It lets you define the structure of the file system in your code and perform reading and writing in your code as well. So you can read from and write to any archive format you need.
PowerShell (PSH) offers the ability to create "Providers" which allow various resources to be treated like a file system (including the file system, registry, active directory) at various levels of capability down to simple name-value lists (e.g. dir env:
will list all environment variables as content of the env:
drive).
PowerShell can also be embedded in in a .NET application: roughly speaking create a Runspace
and then execute commands and scripts in it, including loading a PSH Module which includes a custom provider. Properties on the Runspace
instance allow access to the drives and their providers.
精彩评论