473,396 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Read Text VB.net vs. VB6 difference

DJ
ANY HELP FROM THE MASTERS GREATLY APPRECIATED

When reading textfiles with VB.net, some special character text is
deleted that does not happen with VB6 (Please see below)

ORIGINAL TEXT FILE
"This is a sentence with a spe·ci·fic word." (Note the dot separators
(Hex B7) in the word 'specific' which are syllable breaks).

VB.NET APPLICATION CODE
Dim sr As System.IO.StreamReader = System.IO.File.OpenText(Orginial
file Name)
Console.Write(sr.ReadToEnd)
sr.Close()

CONSOLE OUTPUT
(Or file output or Access record write which I have tried with same
results)

"This is a sentence with a specific word."
(Note the dot separators (Hex B7) in the word 'specific' are GONE?)

HELP
If I do the same thing in VB6, the dot separators (Hex B7) in the word
'specific' REMAIN (spe·ci·fic). Something in the VB.net readtoend
method is deleting the Hex B7 characters. I have also tried the
VB.Net readline method with same readtoend method results.

I want to keep the dot separators! Any ideas????? I hope not to have
to read the file a byte at a time :<(

Thank you!!!!
Nov 21 '05 #1
2 5473
The OpenText method opens a file using UTF8 encoding. Use this syntax
instead to set the encoding. You may need to change the encoding based on
what encoding was used to write the file.

Dim sr As New StreamReader(New FileStream("<file path here>",
FileMode.Open), System.Text.Encoding.Default)
Dim s As String = sr.ReadToEnd
sr.Close()

"DJ" <te**@spanishsaver.com> wrote in message
news:de**************************@posting.google.c om...
ANY HELP FROM THE MASTERS GREATLY APPRECIATED

When reading textfiles with VB.net, some special character text is
deleted that does not happen with VB6 (Please see below)

ORIGINAL TEXT FILE
"This is a sentence with a spe·ci·fic word." (Note the dot separators
(Hex B7) in the word 'specific' which are syllable breaks).

VB.NET APPLICATION CODE
Dim sr As System.IO.StreamReader = System.IO.File.OpenText(Orginial
file Name)
Console.Write(sr.ReadToEnd)
sr.Close()

CONSOLE OUTPUT
(Or file output or Access record write which I have tried with same
results)

"This is a sentence with a specific word."
(Note the dot separators (Hex B7) in the word 'specific' are GONE?)

HELP
If I do the same thing in VB6, the dot separators (Hex B7) in the word
'specific' REMAIN (spe·ci·fic). Something in the VB.net readtoend
method is deleting the Hex B7 characters. I have also tried the
VB.Net readline method with same readtoend method results.

I want to keep the dot separators! Any ideas????? I hope not to have
to read the file a byte at a time :<(

Thank you!!!!

Nov 21 '05 #2
DJ
Thank you Russell!!!

Your suggestion to open a filestream with encoding argument worked
like a charm!

Thank you for your time and effort.

DJ

NEW CODE

Dim sr As New System.IO.StreamReader(New
System.IO.FileStream(strMyFile", IO.FileMode.Open),
System.Text.Encoding.Default)

Console.Write(sr.ReadToEnd)

sr.Close()
Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Guyon Morée | last post by:
what is the difference? if I open a text file in binary (rb) mode, it doesn't matter... the read() output is the same.
2
by: Profetas | last post by:
I have the following code that detects a <c> and </c> #include <stdio.h> main(int argc, char *argv) { FILE* fp; char data;
7
by: JerryW | last post by:
I just reinstalled .NET 2003 (after repeated attempts to get ASP.NET Web Applications to work). I first did a complete uninstall of .NET 2003, .NET Framework 1.1, and IIS. I also completely deleted...
2
by: yezi | last post by:
Hi, ALl: The following code is to canculate 2 vector distance. Suppose the vectore is stored in some txt file like -1 0.34 0 0.045 1 0.98 1 0.01
35
by: RyanS09 | last post by:
Hello- I am trying to write a snippet which will open a text file with an integer on each line. I would like to read the last integer in the file. I am currently using: file = fopen("f.txt",...
0
by: rascal_mon | last post by:
I'm new with XML. Please give me some advice. I wonder there are any difference between XML that is automatically generated from ADO and XML file that shows in many textbooks. I found that the...
11
by: jean-jeanot | last post by:
I can access to a file with the command: file_obj = open ( " D:\My documents\Textfile.txt",'r') When I now try to read a file with the following command: file_obj = open ("D:\My...
3
by: =?Utf-8?B?ZGF2aWQ=?= | last post by:
I try to follow Steve's paper to build a database, and store a small text file into SQL Server database and retrieve it later. Only difference between my table and Steve's table is that I use NTEXT...
1
by: Matrixinline | last post by:
Hi All, File Text.txt Contains following text as : "C:\program file\application data\details\app" "D:\Program File" I tried to read that data as fscanf(oFp, "%s %s", sCopyDirectory,...
11
by: casucci | last post by:
I do a return as XMLDataDocument in my webservice but it returns not with the namespaces etc in them. Anyone have and example where I can have the webservice return it as a XML. C# preferred....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.