using System; using System.IO; class Test { public static void Main() { string path = @"c:\temp\MyTest.txt"; if (!File.Exists(path)) { // Create a file to write to. using (StreamWriter sw = File.CreateText(path)) { sw.WriteLine("Hello"); sw.WriteLine("And"); sw.WriteLine("Welcome"); } } // Open the file to read from. using (StreamReader sr = File.OpenText(path)) { string s = ""; while ((s = sr.ReadLine()) != null) { Console.WriteLine(s); } } } }
All the question that scared me now i am trying to scare them .. so that they cant scare others :)
Thursday, October 6, 2011
Creates or opens a file for writing
Subscribe to:
Post Comments (Atom)
Featured Posts
Installing vim openssh server openssh client build essential net tools i...
Installing Essential Packages in Ubuntu: `vim`, `opensshserver`, `opensshclient`, `buildessential`, and `nettools` When working on an Ubuntu...
-
Configuration config = HBaseConfiguration.create(); Job job = new Job(config,"ExampleReadWrite"); job.setJarByClass(MyReadWriteJo...
-
Print numbers in order : #!/bin/bash for i in $(seq 0 4) do for j in $(seq $i -1 0) do echo -n $j done echo done Will gi...
No comments:
Post a Comment
Thank you for Commenting Will reply soon ......