473,398 Members | 2,188 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,398 software developers and data experts.

StreamWriter problem

I am using VB.NET 2005 and streamWriter to write to a file.
Before writing to the file, I encrypt the string.
StreamWriter does not write it correctly to the file, I have to change to
FileOpen, Print and FileClose to write it correctly to a file.
StreamWriter will write something like:
ÃzÃ,Ãz¬±°±¸²¬Ã,±°°²¬ÃSáòöéóüÂ
instead of
ÞÂÞ¬±°±¸²¬Â±°°²¬Êáòöéóü

Why does StreamWriter write it incorrectly ? Can I write those ascii
characters using StreamWriter ?
Thank you.

Dim swFile As StreamWriter

Crypt(Account1)
swFile = New streamWriter("c:\test.HTM", False)
swFile.Write(re)
swFile.Close()

Public Function Crypt(ByVal Text As String) As String
Dim strTempChar As String
Dim I As Int16

For I = 1 To Len(Text)
strTempChar = Asc(Mid$(Text, I, 1)) + {some number}
Mid$(Text, I, 1) = Chr(strTempChar)
Next I
Crypt = Text
Nov 6 '07 #1
3 1938
"fniles" <fn****@pfmail.comschrieb:
>I am using VB.NET 2005 and streamWriter to write to a file.
Before writing to the file, I encrypt the string.
StreamWriter does not write it correctly to the file, I have to change to
FileOpen, Print and FileClose to write it correctly to a file.
StreamWriter will write something like:
ÃzÃ,Ãz¬±°±¸²¬Ã,±°°²¬ÃSáòöéóüÂ
instead of
ÞÂÞ¬±°±¸²¬Â±°°²¬Êáòöéóü

Why does StreamWriter write it incorrectly ? Can I write those ascii
characters using StreamWriter ?
'StreamWriter' uses the UTF-8 encoding by default. Maybe the application
you are using to view the file assumes or expects another encoding. The
'StreamWriter' class' constructor is overloaded---one overload expects a
'System.Text.Encoding' object.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 6 '07 #2
"Herfried K. Wagner [MVP]" <hi***************@gmx.atwrote in message
news:ej**************@TK2MSFTNGP02.phx.gbl...
"fniles" <fn****@pfmail.comschrieb:
>>I am using VB.NET 2005 and streamWriter to write to a file.
Before writing to the file, I encrypt the string.
StreamWriter does not write it correctly to the file, I have to change to
FileOpen, Print and FileClose to write it correctly to a file.
StreamWriter will write something like:
ÃzÃ,Ãz¬±°±¸²¬Ã,±°°²¬ÃSáòöéóüÂ
instead of
ÞÂÞ¬±°±¸²¬Â±°°²¬Êáòöéóü

Why does StreamWriter write it incorrectly ? Can I write those ascii
characters using StreamWriter ?

'StreamWriter' uses the UTF-8 encoding by default. Maybe the application
you are using to view the file assumes or expects another encoding. The
'StreamWriter' class' constructor is overloaded---one overload expects a
'System.Text.Encoding' object.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
You are the man, Herfried! Just another reason why VB 2005 is so cool... The
language requires considerable study. I have found that I was not able to
beat it into the VB6 shape (grin). Consequently, my coding has improved
hugely.

Herfried, while on the subject of VS 2005, what are your observations of VS
2008?
Nov 7 '07 #3
"Harry" <so*****@microsoft.com.auschrieb:
Herfried, while on the subject of VS 2005, what are your observations of
VS 2008?
Unfortunately I didn't yet have the opportunity to work with VS 2008 :-/.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 7 '07 #4

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

Similar topics

1
by: Bob Hansen | last post by:
I am having a very strange problem with StreamWriter and writing to files. I have a procedure that is called several times to write out seperate files, each of them uniquely named by date all they...
1
by: Lars Hansen | last post by:
Hi This is probably pretty basic, but I have a problem with the access-level (local variable), when creating a new StreamWriter. I am trying to write some price information to a textfile - which...
13
by: Rob Corwin | last post by:
Hi, a c# app of mine that parses 30,000 xml files writes large amounts of data to file (> 2GB) using a streamwriter object (sw). everything works fine except that the memory used by the app grows...
5
by: Rob Corwin | last post by:
Hi, a c# app of mine that parses 30,000 xml files writes large amounts of data to flat file (> 2GB) using a streamwriter object (sw). everything works fine except that the memory used by the app...
5
by: Brendan Miller | last post by:
Hi, I have been having a problem writing the contents of a dataset to a .csv file. When I write to a .csv file and open it with either Excel or Wordpad the "french" characters are wrong. When I...
9
by: ShadowOfTheBeast | last post by:
Hi, I have got a major headache understanding streamReader and streamWriter relationship. I know how to use the streamreader and streamwriter independently. but how do you write out using the...
10
by: Oscar Thornell | last post by:
Hi, I generate and temporary saves a text file to disk. Later I upload this file to Microsoft MapPoint (not so important). The file needs to be in UTF-8 encoding and I explicitly use the...
5
by: ramendra | last post by:
Hello there, I am having some problem with using StreamWriter object in aspnet application. The thing is when i use the streamwriter in an aspnet page the code gets executed fine but its...
2
by: gordon | last post by:
Hi, I am trying to create a reference to an external file to write to using stream writer and a value that is created in a for. Basically the value that a user will create will be the name...
4
by: Heron | last post by:
Hi, Could someone explain me why the following code doesn't work? The memorystream always remains with length 0. MemoryStream input = new MemoryStream();
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.