开发者

Does Dokan/Dokan.NET (not) support synchronous I/O?

I created a virtual drive in C# using the Dokan(.NET) library, and it's working quite well.

However, when I try to read a file from the drive in another application I get an exception whenever using operations that read synchronously, like System.IO.File.ReadAllText(...).

The text of the exception is: "Handle does not support synchronous oper开发者_如何学运维ations. The parameters to the FileStream constructor may need to be changed to indicate that the handle was opened asynchronously".

So if I am interpreting this correctly, .NET apparently tries to read the entire content of the file in a single synchronous operation, but Dokan does not seem to allow that.

But when using a method like ReadAllText I don't really have any control over the way the FileStream is constructed (isn't that the whole point of that method, after all, simply get the file content without having to bother with Streams and Readers and Buffers and whatnot?).

Can I get Dokan to support synchronous I/O access on it's file handles somehow? Or do I have to somehow live with the fact that synchronous operations are just not possible on Dokan-hosted files (and hope that no application that might ever have to work on my virtual drive depends on them)?


Any reason why you need synchronicity in the file read? You could do an async read to a stream, and handle when it finishes via a callback.

This has a good presentation/tutorial on different ways to do async file i/o:

msdn async file io

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜