删除文件结束 [英] Delete End of File

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

问题描述

举例来说,如果我叫WriteFile的一个文件的末尾,后来我想删除写入的字节,我怎么能做到这一点?我一定要读文件的内容到缓冲区中,重新创建该文件,并写入所需的字节数,或者是有一个更简单的方法?

For instance if I called WriteFile to the end of a file, and later I wanted to delete the written bytes, how could I do this? Do I have to read the file's contents into a buffer, re-create the file, and write the desired bytes, or is there an easier way?

推荐答案

寻求你想从截断的文件位置(如果你不是已经在那里),然后调用恰当地命名的 SetEndOfFile()函数

Seek to the file position you want to truncate from (if you're not already there), then call the aptly-named SetEndOfFile() function.

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

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