开发者社区> 问答> 正文

flose不关闭音频文件

我有下面的C++代码来编写简短的无头音频文件:

vector<short>nShrtDecoded;
nShrtDecoded.resize(iCountDecodedShorts);//-1

//Then I fill the vector of short with some audio. I didn't write that length code here. I think it doesn't matter anyway HOW exactley I fill this vector of shorts

FILE* outfile = fopen("d:\\!wavs\\weg.raw", "wb");
fwrite(&nShrtDecoded[0], sizeof(short), nShrtDecoded.size(), outfile);
fclose(outfile);

我在Debug模式下运行这段代码,并且在“flose(Outfile)”行后面的行中设置了一个断点。

一旦命中此断点,我将尝试使用Windows Explorer删除该文件。这应该可以工作,因为文件已经使用“flose”关闭了。

当我试图删除文件“d:\WAVS\weg.raw”时,Windows告诉我“使用中的文件:由于其他程序正在使用该文件,操作无法完成”:

enter image description here

因为我不认为这是真的,我点燃了洛克亨特。洛克亨特告诉我如下:

enter image description here

有谁知道这种奇怪的行为是由什么引起的?

展开
收起
aqal5zs3gkqgc 2019-12-19 20:10:23 3102 0
1 条回答
写回答
取消 提交回答
  • 我找到了罪魁祸首:

    我以并行的方式运行这个函数。

    这就解释了一切。

    2019-12-19 20:11:06
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载