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
Post a Comment