如何使用c++使用流的方法删除文件
how to delete the file using method of ofstream using c++?
我正在使用流输出到一个文件,然后我想在程序结束时擦除该文件。是否有fstream的方法或任何允许我删除文件的方法?
std::fstream不提供文件系统操作,它只提供文件操作。
您可以使用应该适用于大多数编译器的C stdio remove:
/* remove example: remove myfile.txt */
#include <stdio.h>
int main ()
{
if( remove( "myfile.txt" ) != 0 )
perror( "Error deleting file" );
else
puts( "File successfully deleted" );
return 0;
}
相关文章:
- 检测win32服务创建和删除的最佳方法
- 尝试了解在导入的静态方法上使用删除方法时的错误
- 一种从内存中删除 UTF 字节的方法?
- 从数组中删除非唯一值、保持顺序和不使用向量的最佳方法?
- 在析构函数中删除单链表的正确方法是什么?
- 处理从列表中删除指向对象的指针的"healthy"方法是什么?
- 删除类成员的动态分配内存的最佳方法是什么
- 从浮点数中删除小数部分但保留类型的有效方法
- 如果方法在类中定义,则阻止编译器删除方法
- 删除复制构造函数的 Intel 13.1.2 中不良C++行为的解决方法
- 有没有一种预处理器的方法可以从调试符号中删除代码段
- 删除父/子窗口层次结构的最佳方法
- 工厂方法创建的对象应该在哪里删除?
- 如何通过最快的方法删除指定的标签组件
- 无法使用擦除方法删除矢量的最后一个元素
- 尝试使用窗口注册表中的路径和 DeleteFile() 方法删除.exe文件
- 通过此方法删除链表中的数据会发生什么情况
- 如何使用c++使用流的方法删除文件
- 如何通过析构函数方法删除对象(类)
- 标准的c++11方法删除一个类型的所有指针