简体   繁体   中英

Writing constantly Data into a File

My Program ist getting alot and very frequently Data, up to 2-4 Times per second. My Goal is to take this Data and write it into a File. My Question now, is it smart to having a File-Pointer constantly open? May it be better to just cache the Data first and then write it into a File? How is the perfomance?

Are there Design-Patterns which are good for this? Any Tips are welcome.

Actually buffering is already implemented in standard System.IO.FileStream http://msdn.microsoft.com/en-us/library/system.io.filestream.aspx
Instead of constant writing all changes are accumulated in buffer and flush to disk as buffer getting full. Just remember specify buffer in constructor and call flush as you finish.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM