Files is not been written c# -


can point me what's wrong code? trying write file, nothing gets written file. sorry stupid question.. file gets created nothing written on it.

public static void main(string[] args) {     streamwriter writer = new streamwriter(@"c:\file\test.txt");     writer.writeline("fun times!");     console.writeline("finally !");     console.readline(); } 

you're not closing file. 1 way wrap writer in using statement:

using(streamwriter writer = new streamwriter(@"c:\file\test.txt")) {     writer.writeline("fun times!"); }  console.writeline("finally !"); console.readline(); 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -