That works better with this :
var fso = new ActiveXObject("Scripting.FileSystemObject");
var a = fso.CreateTextFile("c:\\testfile.txt", true);
a.WriteLine("This is a test.");
a.Close();
http://msdn.microsoft.com/en-us/library/5t9b5c0c(v=vs.84).aspx