From df40f345b085d96287c5d57c9cb63c8403b3a97f Mon Sep 17 00:00:00 2001 From: albert-du <52804499+albert-du@users.noreply.github.com> Date: Wed, 1 Jun 2022 17:21:00 -0700 Subject: [PATCH] BinaryReader F# snippets --- .../BinaryReader/BaseStream/fs.fsproj | 10 ++++ .../BinaryReader/BaseStream/rwdouble.fs | 32 ++++++++++++ .../System.IO/BinaryReader/Overview/fs.fsproj | 11 ++++ .../System.IO/BinaryReader/Overview/source.fs | 33 ++++++++++++ .../BinaryReader/Overview/source5.fs | 50 +++++++++++++++++++ .../System.IO/BinaryReader/Read/fs.fsproj | 12 +++++ .../BinaryReader/Read/rwreadbytes.fs | 29 +++++++++++ .../System.IO/BinaryReader/Read/rwreadchar.fs | 29 +++++++++++ .../BinaryReader/Read/rwreadchars.fs | 25 ++++++++++ .../System.IO/BinaryReader/ReadByte/fs.fsproj | 10 ++++ .../System.IO/BinaryReader/ReadByte/rwbyte.fs | 33 ++++++++++++ .../BinaryReader/ReadBytes/fs.fsproj | 10 ++++ .../BinaryReader/ReadBytes/rwbytes.fs | 35 +++++++++++++ .../System.IO/BinaryReader/ReadChar/fs.fsproj | 10 ++++ .../System.IO/BinaryReader/ReadChar/rwchar.fs | 26 ++++++++++ .../BinaryReader/ReadChars/fs.fsproj | 10 ++++ .../BinaryReader/ReadChars/rwchars.fs | 22 ++++++++ xml/System.IO/BinaryReader.xml | 17 +++++++ 18 files changed, 404 insertions(+) create mode 100644 snippets/fsharp/System.IO/BinaryReader/BaseStream/fs.fsproj create mode 100644 snippets/fsharp/System.IO/BinaryReader/BaseStream/rwdouble.fs create mode 100644 snippets/fsharp/System.IO/BinaryReader/Overview/fs.fsproj create mode 100644 snippets/fsharp/System.IO/BinaryReader/Overview/source.fs create mode 100644 snippets/fsharp/System.IO/BinaryReader/Overview/source5.fs create mode 100644 snippets/fsharp/System.IO/BinaryReader/Read/fs.fsproj create mode 100644 snippets/fsharp/System.IO/BinaryReader/Read/rwreadbytes.fs create mode 100644 snippets/fsharp/System.IO/BinaryReader/Read/rwreadchar.fs create mode 100644 snippets/fsharp/System.IO/BinaryReader/Read/rwreadchars.fs create mode 100644 snippets/fsharp/System.IO/BinaryReader/ReadByte/fs.fsproj create mode 100644 snippets/fsharp/System.IO/BinaryReader/ReadByte/rwbyte.fs create mode 100644 snippets/fsharp/System.IO/BinaryReader/ReadBytes/fs.fsproj create mode 100644 snippets/fsharp/System.IO/BinaryReader/ReadBytes/rwbytes.fs create mode 100644 snippets/fsharp/System.IO/BinaryReader/ReadChar/fs.fsproj create mode 100644 snippets/fsharp/System.IO/BinaryReader/ReadChar/rwchar.fs create mode 100644 snippets/fsharp/System.IO/BinaryReader/ReadChars/fs.fsproj create mode 100644 snippets/fsharp/System.IO/BinaryReader/ReadChars/rwchars.fs diff --git a/snippets/fsharp/System.IO/BinaryReader/BaseStream/fs.fsproj b/snippets/fsharp/System.IO/BinaryReader/BaseStream/fs.fsproj new file mode 100644 index 00000000000..98c19104d32 --- /dev/null +++ b/snippets/fsharp/System.IO/BinaryReader/BaseStream/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System.IO/BinaryReader/BaseStream/rwdouble.fs b/snippets/fsharp/System.IO/BinaryReader/BaseStream/rwdouble.fs new file mode 100644 index 00000000000..bfc868782bf --- /dev/null +++ b/snippets/fsharp/System.IO/BinaryReader/BaseStream/rwdouble.fs @@ -0,0 +1,32 @@ +// +open System +open System.IO + +let arrayLength = 1000 + +// Create random data to write to the stream. +let randomGenerator = Random() +let dataArray = + Array.init arrayLength (fun _ -> 100.1 * randomGenerator.NextDouble()) +do + use binWriter = new BinaryWriter(new MemoryStream()) + // Write the data to the stream. + printfn $"Writing data to the stream." + for num in dataArray do + binWriter.Write num + + // Create a reader using the stream from the writer. + use binReader = new BinaryReader(binWriter.BaseStream) + try + // Return to the beginning of the stream. + binReader.BaseStream.Position <- 0 + + // Read and verify the data. + printfn "Verifying the written data." + for num in dataArray do + if binReader.ReadDouble() <> num then + printfn "Error writing data." + printfn "The data was written and verified." + with :? EndOfStreamException as e -> + printfn $"Error writing data: {e.GetType().Name}." +// \ No newline at end of file diff --git a/snippets/fsharp/System.IO/BinaryReader/Overview/fs.fsproj b/snippets/fsharp/System.IO/BinaryReader/Overview/fs.fsproj new file mode 100644 index 00000000000..eed01845d39 --- /dev/null +++ b/snippets/fsharp/System.IO/BinaryReader/Overview/fs.fsproj @@ -0,0 +1,11 @@ + + + Exe + net6.0 + + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System.IO/BinaryReader/Overview/source.fs b/snippets/fsharp/System.IO/BinaryReader/Overview/source.fs new file mode 100644 index 00000000000..70e7857025e --- /dev/null +++ b/snippets/fsharp/System.IO/BinaryReader/Overview/source.fs @@ -0,0 +1,33 @@ +module source + +// +open System.IO +open System.Text + +let fileName = "AppSettings.dat" + +let writeDefaultValues () = + use stream = File.Open(fileName, FileMode.Create) + use writer = new BinaryWriter(stream, Encoding.UTF8, false) + writer.Write 1.250F + writer.Write @"c:\Temp" + writer.Write 10 + writer.Write true + +let displayValues () = + if File.Exists fileName then + use stream = File.Open(fileName, FileMode.Open) + use reader = new BinaryReader(stream, Encoding.UTF8, false) + let aspectRatio = reader.ReadSingle() + let tempDirectory = reader.ReadString() + let autoSaveTime = reader.ReadInt32() + let showStatusBar = reader.ReadBoolean() + + printfn $"Aspect ratio set to: {aspectRatio}" + printfn $"Temp directory is: {tempDirectory}" + printfn $"Auto save time set to: {autoSaveTime}" + printfn $"Show status bar: {showStatusBar}" + +writeDefaultValues () +displayValues () +// \ No newline at end of file diff --git a/snippets/fsharp/System.IO/BinaryReader/Overview/source5.fs b/snippets/fsharp/System.IO/BinaryReader/Overview/source5.fs new file mode 100644 index 00000000000..ffc4846a222 --- /dev/null +++ b/snippets/fsharp/System.IO/BinaryReader/Overview/source5.fs @@ -0,0 +1,50 @@ +module source5 + +// +open System +open System.IO +open System.Text + +let CHUNK_SIZE = 1024 + +let dumpBytes (bdata: byte[]) len = + let mutable j = 0 + // 3 * 16 chars for hex display, 16 chars for text and 8 chars + // for the 'gutter' int the middle. + let dumptext = StringBuilder(" ", 16 * 4 + 8) + for i = 0 to len - 1 do + dumptext.Insert(j * 3, $"{int bdata[i]:X2} ") |> ignore + let dchar = char bdata[i] + //' replace 'non-printable' chars with a '.'. + let dchar = + if Char.IsWhiteSpace dchar || Char.IsControl dchar then + '.' + else + dchar + dumptext.Append dchar |> ignore + j <- j + 1 + if j = 16 then + printfn $"{dumptext}" + dumptext.Length <- 0 + dumptext.Append " " |> ignore + j <- 0 + // display the remaining line + if j > 0 then + for i = j to 15 do + dumptext.Insert(j * 3, " ") |> ignore + printfn $"{dumptext}" + +[] +let main args = + if args.Length = 0 || File.Exists args[0] |> not then + printfn "Please provide an existing file name." + else + use fs = new FileStream(args[0], FileMode.Open, FileAccess.Read) + use br = new BinaryReader(fs, ASCIIEncoding()) + + let mutable chunk = br.ReadBytes CHUNK_SIZE + while chunk.Length > 0 do + dumpBytes chunk chunk.Length + chunk <- br.ReadBytes CHUNK_SIZE + 0 +// \ No newline at end of file diff --git a/snippets/fsharp/System.IO/BinaryReader/Read/fs.fsproj b/snippets/fsharp/System.IO/BinaryReader/Read/fs.fsproj new file mode 100644 index 00000000000..3fb0526951a --- /dev/null +++ b/snippets/fsharp/System.IO/BinaryReader/Read/fs.fsproj @@ -0,0 +1,12 @@ + + + Exe + net6.0 + + + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System.IO/BinaryReader/Read/rwreadbytes.fs b/snippets/fsharp/System.IO/BinaryReader/Read/rwreadbytes.fs new file mode 100644 index 00000000000..16b42a8a1bc --- /dev/null +++ b/snippets/fsharp/System.IO/BinaryReader/Read/rwreadbytes.fs @@ -0,0 +1,29 @@ +module rwreadbytes + +// +open System +open System.IO + +let arrayLength = 1000 +let dataArray = Array.zeroCreate arrayLength +let verifyArray = Array.zeroCreate arrayLength + +Random().NextBytes dataArray + +do + use binWriter = new BinaryWriter(new MemoryStream()) + printfn "Writing the data." + binWriter.Write(dataArray, 0, arrayLength) + + use binReader = new BinaryReader(binWriter.BaseStream) + binReader.BaseStream.Position <- 0 + + if binReader.Read(verifyArray, 0, arrayLength) <> arrayLength then + printfn "Error writing the data." + else + for i = 0 to arrayLength - 1 do + if verifyArray[i] <> dataArray[i] then + printfn "Error writing the data." + else + printfn "The data was written and verified." +// \ No newline at end of file diff --git a/snippets/fsharp/System.IO/BinaryReader/Read/rwreadchar.fs b/snippets/fsharp/System.IO/BinaryReader/Read/rwreadchar.fs new file mode 100644 index 00000000000..5a72329996f --- /dev/null +++ b/snippets/fsharp/System.IO/BinaryReader/Read/rwreadchar.fs @@ -0,0 +1,29 @@ +module rwreadchar + +// +open System +open System.IO + +let invalidPathChars = Path.GetInvalidPathChars() +let memStream = new MemoryStream() +let binWriter = new BinaryWriter(memStream) + +// Write to memory. +printf "Invalid file path characters are: " +for i = 0 to invalidPathChars.Length - 1 do + binWriter.Write invalidPathChars[i] + +// Create the reader using the same MemoryStream +// as used with the writer. +let binReader = new BinaryReader(memStream) + +// Set Position to the beginning of the stream. +memStream.Position <- 0 + +// Read the data from memory and write it to the console. +printf $"{binReader.ReadString()}" +let memoryData = + [| for _ = 0L to memStream.Length - memStream.Position - 1L do + Convert.ToChar(binReader.Read()) |] +printfn $"{memoryData}" +// \ No newline at end of file diff --git a/snippets/fsharp/System.IO/BinaryReader/Read/rwreadchars.fs b/snippets/fsharp/System.IO/BinaryReader/Read/rwreadchars.fs new file mode 100644 index 00000000000..48c3697e632 --- /dev/null +++ b/snippets/fsharp/System.IO/BinaryReader/Read/rwreadchars.fs @@ -0,0 +1,25 @@ +// +open System.IO + +let invalidPathChars = Path.GetInvalidPathChars() +let memStream = new MemoryStream() +let binWriter = new BinaryWriter(memStream) + +// Write to memory. +binWriter.Write "Invalid file path characters are: " +binWriter.Write(invalidPathChars, 0, invalidPathChars.Length) + +// Create the reader using the same MemoryStream +// as used with the writer. +let binReader = new BinaryReader(memStream) + +// Set Position to the beginning of the stream. +memStream.Position <- 0 + +// Read the data from memory and write it to the console. +printf $"{binReader.ReadString()}" +let arraySize = memStream.Length - memStream.Position |> int +let memoryData = Array.zeroCreate arraySize +binReader.Read(memoryData, 0, arraySize) |> ignore +printfn $"{memoryData}" +// \ No newline at end of file diff --git a/snippets/fsharp/System.IO/BinaryReader/ReadByte/fs.fsproj b/snippets/fsharp/System.IO/BinaryReader/ReadByte/fs.fsproj new file mode 100644 index 00000000000..e81aa3ba44e --- /dev/null +++ b/snippets/fsharp/System.IO/BinaryReader/ReadByte/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System.IO/BinaryReader/ReadByte/rwbyte.fs b/snippets/fsharp/System.IO/BinaryReader/ReadByte/rwbyte.fs new file mode 100644 index 00000000000..3e3759103ca --- /dev/null +++ b/snippets/fsharp/System.IO/BinaryReader/ReadByte/rwbyte.fs @@ -0,0 +1,33 @@ +// +open System +open System.IO + +// Create random data to write to the stream. +let writeArray = Array.zeroCreate 1000 +Random().NextBytes writeArray + +let binWriter = new BinaryWriter(new MemoryStream()) +let binReader = new BinaryReader(binWriter.BaseStream) + +try + // Write the data to the stream. + printfn "Writing the data." + for i = 0 to writeArray.Length - 1 do + binWriter.Write writeArray[i] + + // Set the stream position to the beginning of the stream. + binReader.BaseStream.Position <- 0 + + let mutable failed = false + // Read and verify the data from the stream. + for i = 0 to writeArray.Length - 1 do + if binReader.ReadByte() <> writeArray[i] then + printfn "Error writing the data." + failed <- true + if not failed then + printfn "The data was written and verified." + +// Catch the EndOfStreamException and write an error message. +with :? EndOfStreamException as e -> + printfn $"Error writing the data.\n{e.GetType().Name}" +// \ No newline at end of file diff --git a/snippets/fsharp/System.IO/BinaryReader/ReadBytes/fs.fsproj b/snippets/fsharp/System.IO/BinaryReader/ReadBytes/fs.fsproj new file mode 100644 index 00000000000..1325d007ba8 --- /dev/null +++ b/snippets/fsharp/System.IO/BinaryReader/ReadBytes/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System.IO/BinaryReader/ReadBytes/rwbytes.fs b/snippets/fsharp/System.IO/BinaryReader/ReadBytes/rwbytes.fs new file mode 100644 index 00000000000..b5ce1a1eee4 --- /dev/null +++ b/snippets/fsharp/System.IO/BinaryReader/ReadBytes/rwbytes.fs @@ -0,0 +1,35 @@ +// +open System +open System.IO + +let arrayLength = 1000 + +// Create random data to write to the stream. +let dataArray = Array.zeroCreate arrayLength +Random().NextBytes dataArray + +let binWriter = new BinaryWriter(new MemoryStream()) + +// Write the data to the stream.ch +printfn "Writing the data." +binWriter.Write dataArray + +// Create the reader using the stream from the writer. +let binReader = new BinaryReader(binWriter.BaseStream) + +// Set Position to the beginning of the stream. +binReader.BaseStream.Position <- 0 + +// Read and verify the data. +let verifyArray = binReader.ReadBytes arrayLength +if verifyArray.Length <> arrayLength then + printfn "Error writing the data." +else + let mutable failed = false + for i = 0 to arrayLength - 1 do + if verifyArray[i] <> dataArray[i] then + printfn "Error writing the data." + failed <- true + if not failed then + printfn "The data was written and verified." +// \ No newline at end of file diff --git a/snippets/fsharp/System.IO/BinaryReader/ReadChar/fs.fsproj b/snippets/fsharp/System.IO/BinaryReader/ReadChar/fs.fsproj new file mode 100644 index 00000000000..873e5b4d33f --- /dev/null +++ b/snippets/fsharp/System.IO/BinaryReader/ReadChar/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System.IO/BinaryReader/ReadChar/rwchar.fs b/snippets/fsharp/System.IO/BinaryReader/ReadChar/rwchar.fs new file mode 100644 index 00000000000..9925e53e266 --- /dev/null +++ b/snippets/fsharp/System.IO/BinaryReader/ReadChar/rwchar.fs @@ -0,0 +1,26 @@ +// +open System.IO + +let invalidPathChars = Path.GetInvalidPathChars() +let memStream = new MemoryStream() +let binWriter = new BinaryWriter(memStream) + +// Write to memory. +binWriter.Write "Invalid file path characters are: " +for i = 0 to invalidPathChars.Length - 1 do + binWriter.Write invalidPathChars[i] + +// Create the reader using the same MemoryStream +// as used with the writer. +let binReader = new BinaryReader(memStream) + +// Set Position to the beginning of the stream. +memStream.Position <- 0 + +// Read the data from memory and write it to the console. +printf $"{binReader.ReadString()}" +let memoryData = Array.zeroCreate (int (memStream.Length - memStream.Position)) +for i = 0 to memoryData.Length - 1 do + memoryData[i] <- binReader.ReadChar() +printfn $"{memoryData}" +// \ No newline at end of file diff --git a/snippets/fsharp/System.IO/BinaryReader/ReadChars/fs.fsproj b/snippets/fsharp/System.IO/BinaryReader/ReadChars/fs.fsproj new file mode 100644 index 00000000000..e2024ac71d3 --- /dev/null +++ b/snippets/fsharp/System.IO/BinaryReader/ReadChars/fs.fsproj @@ -0,0 +1,10 @@ + + + Exe + net6.0 + + + + + + \ No newline at end of file diff --git a/snippets/fsharp/System.IO/BinaryReader/ReadChars/rwchars.fs b/snippets/fsharp/System.IO/BinaryReader/ReadChars/rwchars.fs new file mode 100644 index 00000000000..cd0f4a69e29 --- /dev/null +++ b/snippets/fsharp/System.IO/BinaryReader/ReadChars/rwchars.fs @@ -0,0 +1,22 @@ +// +open System.IO + +let invalidPathChars = Path.GetInvalidPathChars() +let memStream = new MemoryStream() +let binWriter = new BinaryWriter(memStream) + +// Write to memory. +binWriter.Write "Invalid file path characters are: " +binWriter.Write invalidPathChars + +// Create the reader using the same MemoryStream +// as used with the writer. +let binReader = new BinaryReader(memStream) + +// Set Position to the beginning of the stream. +memStream.Position <- 0 + +// Read the data from memory and write it to the console. +printf $"{binReader.ReadString()}" +printfn $"{binReader.ReadChars(int (memStream.Length - memStream.Position))}" +// \ No newline at end of file diff --git a/xml/System.IO/BinaryReader.xml b/xml/System.IO/BinaryReader.xml index 4afecb3fd80..64a5e0df821 100644 --- a/xml/System.IO/BinaryReader.xml +++ b/xml/System.IO/BinaryReader.xml @@ -83,6 +83,7 @@ The following code example demonstrates how to store and retrieve application settings in a file. :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/Overview/source.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/Overview/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter/VB/source.vb" id="Snippet1"::: ]]> @@ -166,6 +167,7 @@ The following code example demonstrates how to store and retrieve application settings in a file. :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/Overview/source.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/Overview/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter/VB/source.vb" id="Snippet1"::: ]]> @@ -356,6 +358,7 @@ :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/CPP/rwdouble.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/BaseStream/rwdouble.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/BaseStream/rwdouble.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/VB/rwdouble.vb" id="Snippet1"::: ]]> @@ -765,6 +768,7 @@ :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChar2/CPP/rwreadchar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/Read/rwreadchar.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/Read/rwreadchar.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChar2/VB/rwreadchar.vb" id="Snippet1"::: ]]> @@ -931,11 +935,13 @@ The following example shows how to write binary data by using memory as a backing store. It displays a message to the console that indicates whether the data was written correctly. :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/Read/rwreadbytes.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/Read/rwreadbytes.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWBytes2/VB/rwreadbytes.vb" id="Snippet1"::: This example reads the contents of a file and displays each byte's numeric value in 16-column format. The end of the file that is being read is detected when the method returns zero bytes. :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/Overview/source5.cs" id="Snippet6"::: + :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/Overview/source5.fs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter/VB/source5.vb" id="Snippet6"::: ]]> @@ -1029,6 +1035,7 @@ :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChars2/CPP/rwreadchars.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/Read/rwreadchars.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/Read/rwreadchars.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChars2/VB/rwreadchars.vb" id="Snippet1"::: ]]> @@ -1225,6 +1232,7 @@ The following code example demonstrates how to store and retrieve application settings in a file. :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/Overview/source.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/Overview/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter/VB/source.vb" id="Snippet1"::: ]]> @@ -1305,6 +1313,7 @@ :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWByte/CPP/rwbyte.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/ReadByte/rwbyte.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/ReadByte/rwbyte.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWByte/VB/rwbyte.vb" id="Snippet1"::: ]]> @@ -1386,11 +1395,13 @@ :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWBytes1/CPP/rwbytes.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/ReadBytes/rwbytes.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/ReadBytes/rwbytes.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWBytes1/VB/rwbytes.vb" id="Snippet1"::: This example reads the contents of a file and displays it to the console as dump text. The end of the file that is being read is detected when the length of the array returned from is zero. :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/Overview/source5.cs" id="Snippet6"::: + :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/Overview/source5.fs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter/VB/source5.vb" id="Snippet6"::: ]]> @@ -1473,6 +1484,7 @@ :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChar1/CPP/rwchar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/ReadChar/rwchar.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/ReadChar/rwchar.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChar1/VB/rwchar.vb" id="Snippet1"::: ]]> @@ -1556,6 +1568,7 @@ :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChars1/CPP/rwchars.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/ReadChars/rwchars.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/ReadChars/rwchars.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWChars1/VB/rwchars.vb" id="Snippet1"::: ]]> @@ -1702,6 +1715,7 @@ :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/CPP/rwdouble.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/BaseStream/rwdouble.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/BaseStream/rwdouble.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter.RWDouble/VB/rwdouble.vb" id="Snippet1"::: ]]> @@ -1898,6 +1912,7 @@ The following code example demonstrates how to store and retrieve application settings in a file. :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/Overview/source.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/Overview/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter/VB/source.vb" id="Snippet1"::: ]]> @@ -2115,6 +2130,7 @@ The following code example demonstrates how to store and retrieve application settings in a file. :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/Overview/source.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/Overview/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter/VB/source.vb" id="Snippet1"::: ]]> @@ -2192,6 +2208,7 @@ The following code example demonstrates how to store and retrieve application settings in a file. :::code language="csharp" source="~/snippets/csharp/System.IO/BinaryReader/Overview/source.cs" id="Snippet1"::: + :::code language="fsharp" source="~/snippets/fsharp/System.IO/BinaryReader/Overview/source.fs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.IO.BinaryReaderWriter/VB/source.vb" id="Snippet1"::: ]]>