file - c# Save Streamwriter after every 200 Cycles without Closing -


i'm using streamwriter write data file.

system.io.streamwriter file = new system.io.streamwriter(path); while(something_is_happening && my_flag_is_true)      file.writeline(some_text_goes_inside);  file.close(); 

what noticed is, till close called no data written file.

is there way can save contents file before closing.

for purpose can use flush method.

system.io.streamwriter file = new system.io.streamwriter(path); int counter = 0; while(something_is_happening && my_flag_is_true) {     file.writeline(some_text_goes_inside);     counter++;     if(counter < 200) continue;     file.flush();     counter = 0; } file.close(); 

for more information welcome msdn


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -