FileStream with DeleteOnClose File option

孤街浪徒 提交于 2019-12-03 07:03:01
angry person

You need to use | instead of &.

These are binary flags, and when you say &, you effectively mask them all away, resulting in no options at all.

Yuriy Faktorovich

Use FileOptions.DeleteOnClose | FILE_FLAG_NO_BUFFERING the & cancels them out.

FILE_FLAG_NO_BUFFERING & FileOptions.DeleteOnClose returns FileOptions.None

AnthonyWJones

Try including the WriteThrough flag as well in a list using the | operator. See this KB on the requirements for using FILE_FLAG_NO_BUFFERING. Its interesting that MS hasn't included this flag in the enum. Is there a reason why WriteThrough doesn't do what you need in this scenario? You are trying to write secure data?

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!