使用FILE_ATTRIBUTE_TEMPORARY和FILE_FLAG_DELETE_ON_CLOSE [英] Using FILE_ATTRIBUTE_TEMPORARY and FILE_FLAG_DELETE_ON_CLOSE

查看:323
本文介绍了使用FILE_ATTRIBUTE_TEMPORARY和FILE_FLAG_DELETE_ON_CLOSE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的C ++应用程序中创建临时文件时,我使用两个标志 FILE_ATTRIBUTE_TEMPORARY FILE_FLAG_DELETE_ON_CLOSE 根据此博客,不应该在磁盘上创建的任何文件。但在我的代码文件是创建和写入到磁盘(即使1 KB数据)。有人可以确认这些标志的确切功能,以及文件是否在磁盘上创建?

I am using the two flags FILE_ATTRIBUTE_TEMPORARY and FILE_FLAG_DELETE_ON_CLOSE while creating temporary files in my C++ application. According to this blog there shouldn't be any file being created on the disk. But in my code the file is created and written to on disk (even for 1 KB data). Can someone confirm the exact functionality of these flags, and whether the files are created on disk or not?

推荐答案

相同的链接,有引号:


如果超过可用内存,
内存管理器将刷新文件
数据到磁盘。这会导致
的性能损失,但您的操作
将成功而不是失败。

If you exceed available memory, the memory manager will flush the file data to disk. This causes a performance hit, but your operation will succeed instead of failing.

将文件标记为临时将告诉系统它不需要在磁盘上,但它不会阻止它被放在那里。

Marking a file as temporary will tell the system it doesn't need to be on disk, but it doesn't prevent it from being put there, either.

这篇关于使用FILE_ATTRIBUTE_TEMPORARY和FILE_FLAG_DELETE_ON_CLOSE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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