View Single Post
  #4 (permalink)  
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
Default

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:
quote:Originally posted by Monica
 Hi,

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)
        Try
            Dim bFormatter As BinaryFormatter = New BinaryFormatter
            bFormatter.Serialize(flStream, readfile)
        Finally
            flStream.Close()
            objStreamReader.Close()
        End Try
    End Sub

Cheers,
Monica
Reply With Quote