Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] #1893 #2096

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

[BUG] #1893 #2096

wants to merge 1 commit into from

Conversation

gan4-ua
Copy link

@gan4-ua gan4-ua commented Nov 5, 2021

System.UnauthorizedAccessException when running from a shared directory

I didn't actually manage to find any place when you are flushing the files stream without flushing the OS buffer, so it seems to me like you are simply trying to use the unbuffered I/O.

Just followed the recommendations on MSDN:
https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-flushfilebuffers

Due to disk caching interactions within the system, the FlushFileBuffers function can be inefficient when used after every write to a disk drive device when many writes are being performed separately. If an application is performing multiple writes to disk and also needs to ensure critical data is written to persistent media, the application should use unbuffered I/O instead of frequently calling FlushFileBuffers. To open a file for unbuffered I/O, call the CreateFile function with the FILE_FLAG_NO_BUFFERING and FILE_FLAG_WRITE_THROUGH flags. This prevents the file contents from being cached and flushes the metadata to disk with each write. For more information, see CreateFile.

System.UnauthorizedAccessException when running from a shared directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant