Handling with temporary file stream

前端 未结 5 945
南方客
南方客 2021-01-02 22:47

Say I want to define a TempFileStream class that creates a temporary file using Path.GetTempFileName() method. A temporary file must be deleted when TempFileStream\'s object

5条回答
  •  借酒劲吻你
    2021-01-02 23:29

    base.Dispose(disposing); // disposes the base stream so the file is no longer used
    if (disposing)
        File.Delete(m_TempFileName); // deletes the file
    

    You should add proper exception handling for File.Delete if you need to.

提交回复
热议问题