Prasad Godbole

Prasad Godbole

  • NA
  • 153
  • 170.1k

Need Help How to a read a file containing special characters

Oct 12 2006 10:19 AM
We are developing web application with asp.net 1.1 using vb.net.

Problem In Brief :- How to a read file containing 
                  all types of special characters

In this application we save a file using following code


        Dim fso , tf
        sFullPath = SFilePath & "\" & sFileName
        fso = CreateObject("Scripting.FileSystemObject")
        tf = fso.CreateTextFile(sFullPath, True)
        tf.WriteLine(sContents)
        tf.Close()
        fso = Nothing

Here file name will be "test.html" i.e. this file will be saved as html file.

This file contains number of special characters as well as words of german languages

when we read this file using binary reader with following code
(Here we have used binary reader because it reads all special characters)

        Dim oFileStream As FileStream
        Dim oBinaryReader As BinaryReader

        oFileStream = File.Open(FullPath, FileMode.Open)
        oBinaryReader = New BinaryReader
                    (oFileStream,System.Text.Encoding.Default)

        While oBinaryReader.PeekChar() <> -1
              sContent = sContent & oBinaryReader.ReadChar
        End While

It reads the file successfully with all specials characters.

But it reads very slowly and if file size exceeds 30 kb then CPU Utilization becomes 100% this is not good on live server.

So please tell us how we can read the file "test.html" very fastly with all special characters using vb.net/c#.net/j#.net etc. or any other .net supported language in .NET 1.1

Waiting for reply