Appending to a file passing a reference to the writer


I would like to be able to open up a file stream from a high level function and then append down at a low level which is timing critical. I fell that declaring and opening a file stream multiple times a second may impact performance. Is there a clean way to do this?


Who is Participating?
Is it within a same class? You can use a class level variable for holding the reference to streamwriter and then use it across functions.
Miguel OzSoftware EngineerCommented:
You can use viewstate,check:
ViewState["MyValue"] = "1";
Miguel OzSoftware EngineerCommented:
Please disregard my previous post. Wrong answer to your question.
CodeCruiser comment is the way to go if you do not have memory constraints and your program is the only user of the file.
If you are doing logging, you are better off using solutions like log4net:
bartdspAuthor Commented:
Thanks! Sorry to be slow in responding.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.