FILESTREAM与DeleteOnClose文件选项 [英] FileStream with DeleteOnClose File option

查看:318
本文介绍了FILESTREAM与DeleteOnClose文件选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目,我必须创建一个USB设备的一些临时文件,我想删除闭幕。所以我用了code像

In my project I have to create some temp files in an USB device, which I want to delete on Closing. So I used a code like

this.fcommandHandler = new FileStream(TempFileName,
FileMode.CreateNew, FileAccess.ReadWrite,
FileShare.ReadWrite, 512, FileOptions.DeleteOnClose);

它工作正常。但问题是,我想用一个更FileOption,如无缓冲。

It works fine. But the problem is I want to use one more FileOption, like No buffering.

private const FileOptions FILE_FLAG_NO_BUFFERING = (FileOptions)0x20000000;

this.fcommandHandler = new FileStream(TempFileName,
FileMode.CreateNew, FileAccess.ReadWrite,
FileShare.ReadWrite, 512, FileOptions.DeleteOnClose & FILE_FLAG_NO_BUFFERING);

但它不是删除文件后闭幕。请大家帮帮忙。

But its not deleting the File after closing. Please help.

推荐答案

您需要使用|而不是和放大器;

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.

这篇关于FILESTREAM与DeleteOnClose文件选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆