Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
File io 如何刷新D中的文件?_File Io_D - Fatal编程技术网

File io 如何刷新D中的文件?

File io 如何刷新D中的文件?,file-io,d,File Io,D,在D中,我正在向一个文件写入: File opfile = File(opdir~opname, "w"); ... //first gap opfile.writeln("somestuff"); ... //second gap opfile.writeln("otherstuff"); 在本例中,第一个间隔中的内容需要几分钟才能运行,第二个间隔中的内容需要几个小时,我希望在程序结束之前将“something”写入文件,作为一种健全性检查 在我看来,D使用的是缓冲输出,因此,所有的输出在第

在D中,我正在向一个文件写入:

File opfile = File(opdir~opname, "w");
... //first gap
opfile.writeln("somestuff");
... //second gap
opfile.writeln("otherstuff");
在本例中,第一个间隔中的内容需要几分钟才能运行,第二个间隔中的内容需要几个小时,我希望在程序结束之前将“something”写入文件,作为一种健全性检查

在我看来,D使用的是缓冲输出,因此,所有的输出在第二个间隙后立即写入。在C++中,我将使用OFSUT::FLUH在第二个间隙之前手动刷新OpFrase.< D中的等效运算是什么?我在std.file的文档中找不到它。

请参阅

调用文件句柄的fflush


您是否尝试过
opfile.flush()
Ctrl-F“flush”,你应该看到它。我知道这是你所期望的,但我不理解那些反对票。这是一个真正的问题,它目前不在SE上,答案也不在std.file的文档中,而std.file(至少对我来说)是第一个要检查的地方。@JohnDoucette的人倾向于否决Google的问题,或者文档中简单的ctrl+F可以解决的问题。我在文档中查找std.file(),而不是std.stdio。我想这是你第一个想到的。(10分钟限制到期后我接受)