View Single Post
Old June 29th, 2007, 01:51 AM
vishwanath.bmca vishwanath.bmca is offline
Registered User
Join Date: Jun 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

I checked with your code,but its not working its showing same text as what i passed text file,only the first line of the file got affected.
can u check the code and send it once again please

quote:Originally posted by Monica

Here's a sample code to convert a text file to a binary file

Imports System.IO
Imports System.Runtime.Serialization.Formatters.Binary

Public Class Class1

    Public Sub BinarySerialize()
        'Create a streamreader class
        Dim objStreamReader As StreamReader
        'open the file
        objStreamReader = File.OpenText("c:\\Mystore1.txt")
        'Read the file storing it in the readfile string
        Dim readfile As String = objStreamReader.ReadToEnd()
        Dim flStream As FileStream = New FileStream("c:\\myStore.txt", FileMode.OpenOrCreate, FileAccess.Write)
            Dim bFormatter As BinaryFormatter = New BinaryFormatter
            bFormatter.Serialize(flStream, readfile)
        End Try
    End Sub