473,327 Members | 1,967 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,327 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 1934
"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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.