Streamwriter事件如关闭还是已完成?

时间:2012-08-30 13:58:31

标签: c# events streamreader streamwriter

我想在Streamwriter完成工作后直接为Streamreader加注星标。 这必须是这样的,因为Streamreader正在读取Streamwriter写的文件。 提前谢谢!

1 个答案:

答案 0 :(得分:1)

开始输入。编写一个派生自StreamWriter的类并覆盖Dispose

class StreamWriterThatDoesExtraStuffWhenClosed : StreamWriter
{
    public StreamWriterThatDoesExtraStuffWhenClosed(string s) : base(s) { }

    protected override void Dispose(bool f) {
        base.Dispose(f);
        ... do whatever you like here ...
    }
}