Reading and writing binary data (VB) : Binary « File Directory « ASP.NET Tutorial






<%@ Page Language="VB" %>
<%@ Import Namespace="System.IO" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim binarywriter As New BinaryWriter(File.Create("Data.dat"))
        binarywriter.Write("a string")
        binarywriter.Write(&H12346789ABCDEF)
        binarywriter.Write(&H12345678)
        binarywriter.Write("c"c)
        binarywriter.Write(1.5F)
        binarywriter.Write(100.2D)
        binarywriter.Close()

        Dim binaryreader As New BinaryReader(File.Open("Data.dat", FileMode.Open))

        Dim a As String = binaryreader.ReadString()
        Dim l As Long = binaryreader.ReadInt64()
        Dim i As Integer = binaryreader.ReadInt32()
        Dim c As Char = binaryreader.ReadChar()
        Dim f As Double = binaryreader.ReadSingle()
        Dim d As Decimal = binaryreader.ReadDecimal()
        binaryreader.Close()

    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
</body>
</html>








10.11.Binary
10.11.1.Reading and writing binary data (C#)
10.11.2.Reading and writing binary data (VB)