Flushing log to disk, exception in VerifyOSHandlePosition

前端 未结 1 1204
执念已碎
执念已碎 2021-01-27 02:07

How can I write a logfile from a C# service so that it gets flushed to disk in a timely fashion?

Here\'s what I\'ve tried. In logging code, I opened a file like this:

1条回答
  •  深忆病人
    2021-01-27 03:00

    Per this answer, under .NET 4.0 it's enough to just call

    file.Flush(true)
    

    Messing around with the p/Invoke call is no longer required.

    0 讨论(0)
提交回复
热议问题