By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,485 Members | 1,061 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,485 IT Pros & Developers. It's quick & easy.

StreamWriter problem

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
"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

P: n/a
"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

P: n/a
"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 discussion thread is closed

Replies have been disabled for this discussion.