Skip to content

🐞 Issue: Corrupted or Access Denied When Opening PDF via Adobe Reader on Dokan Virtual Drive Summary: #382

@dorbacao

Description

@dorbacao

I'm using Dokan.NET to build a virtual file system. In CreateFile, I fetch PDF bytes from a remote server, save them to disk, and create a FileStream, storing it in info.Context. In ReadFile, I retrieve this stream, set its position using offset, and copy data into the buffer with stream.Read(buffer.Span).

Problem:

When I double-click the PDF file from the virtual drive, Windows copies it to a temporary folder and attempts to open it with Adobe Reader, but the app shows "access denied" or "file corrupted." However, if I manually open the copied file, it’s intact and opens correctly.

Note:

This disk-based approach was implemented only to help isolate the issue. My original design used a service that streamed file chunks on demand, but that didn’t work reliably with Adobe Reader, so I switched to this method for clearer diagnostics.

Relevant Code:

csharp
// CreateFile
File.WriteAllBytes(path, fileBytesFromServer);
info.Context = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);

// ReadFile
stream.Position = offset;
bytesRead = stream.Read(buffer.Span);
Request:

I’d like to know if there are known limitations or best practices for serving large binary files (like PDFs) via Dokan.NET, especially when accessed by applications like Adobe Reader that perform multiple concurrent reads.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions