Read Two Lines, .NET-style

Category:
Input/Output
Description: Line-directed text file input using .NET Stream/StreamReader/StreamWriter abstractions.
Code:
let LineDirectedInputSample3() = 

// Write a test file
System.IO.File.WriteAllLines(@"test.txt", [| "This is a test file.";
"It is easy to read." |]);
// Now read it
let lines = System.IO.File.ReadAllLines @"test.txt"
printfn "%s" (sprintf "%A" lines)

Execution Result:
[|"This is a test file."; "It is easy to read."|]

Last edited Sep 14, 2011 at 2:40 AM by ttliu2000, version 1

Comments

No comments yet.