Emulate hard disk in .NET

2020-04-08 13:47发布

问题:

Is there a way to emulate a disk drive in .NET, intercepting read/write/lock operations?
I would like to create something with a front-end similar to GMail Drive in C#.

Thanks, Tom

回答1:

I use the Eldos Callback File System myself for this purpose, but although it's good, it's not exactly cheap.

There are some free/cheap projects as well, and I'm sure one of them was mentioned in a similar question on SO recently -- can't find it anymore at the moment, though. Stability tends to be a major issue, though, as layered Windows file system drivers aren't trivial.



回答2:

On Linux you can use the Mono.Fuse API (http://www.jprl.com/Projects/mono-fuse.html) to implement .NET-based file systems with user-land code.



回答3:

You could see how http://www.truecrypt.org/ is doing it. It's doing exactly that either by using files or by using a drive or a partition. And then it mounts the file as if it were a real drive. Now, probably that the source code is a bit complex ;)



回答4:

Not really, .Net sits on top of OS functionality like disk access to give you things like managed file accessors.You could write all of it in managed C#, but you'd need unmanaged calls to make the OS treat it like another drive.

All the shell extension stuff is COM: http://msdn.microsoft.com/en-us/library/cc147467(VS.85).aspx

You could, however, write a .Net desktop app that allowed drag-drop from explorer and that looked like a file system view.



回答5:

You could also use EZNamespaceExtension for .NET. This gives you integration with Windows Explorer. Not too expensive given that the license is per developer and not distribution.

Update Big problem with EZNamespaceExtension.NET. It hasn't been updated for a long time. LogicNP seems to have lost their interest in EZNamespaceExtension.NET because there hasn't been a release with new a handful of features since 2010. No .NET 4 support and no support for Windows 8 ribbon toolbar



回答6:

I've just checkout EZNamespaceExtension for .NET with the above link. It seem that they keep up to date as release 2013 version. But not sure that can answer the question of Showing as a Drive in Explorer.exe (AFAIK. it can't show as drive letter)