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

Encoding Text für writing a textfile

Hi everybody,

i have a problem with teh StreamWriter Object. I want to force the Stream to
write an ANSI-text. For reading from an filestream i can define the type of
ASCI by setting
System.Text.Encoding.Default.

What about Wrting Textdate ? The result seems to be UTF7 -Charset, but no
real ANSI.

Any hint for me ?

Martin
Dec 7 '07 #1
4 2144
On Fri, 07 Dec 2007 13:24:05 -0800, Martin Fischer <NO****@nowhere.com>
wrote:
Hi everybody,

i have a problem with teh StreamWriter Object. I want to force the
Stream to
write an ANSI-text. For reading from an filestream i can define the type
of
ASCI by setting
System.Text.Encoding.Default.
What "type of ASCII"? There's only one ASCII. How do you set
System.Text.Encoding.Default, given that it's a read-only property?

As far as the StreamWriter goes, you can specify an encoding via the
constructor when you instantiate the StreamWriter.

Pete
Dec 7 '07 #2
Do you mean you want the file written in plain ASCII?

This appears to produce a simple ASCII text file:

FileStream FS = new FileStream("d:\\myfile.txt",FileMode.OpenOrCreate) ;
StreamWriter SW = new StreamWriter(FS, Encoding.ASCII);

Dec 7 '07 #3
Thanks a lot. Thats what i ve been searching for ...

I have been trying to create a StreamWriter-Object without creating a
previos filestram, and in this structure i didnt find a way to specify the
Encodeng ....

Wish you a nice weekend.

Martin
"RobertK" <ro*****@xmission.comschrieb im Newsbeitrag
news:92**********************************@microsof t.com...
Do you mean you want the file written in plain ASCII?

This appears to produce a simple ASCII text file:

FileStream FS = new FileStream("d:\\myfile.txt",FileMode.OpenOrCreate) ;
StreamWriter SW = new StreamWriter(FS, Encoding.ASCII);

Dec 8 '07 #4
On Fri, 07 Dec 2007 22:45:10 -0800, Martin Fischer <NO****@nowhere.com>
wrote:
I have been trying to create a StreamWriter-Object without creating a
previos filestram, and in this structure i didnt find a way to specify
the
Encodeng ....
Why there's no StreamWriter(String, Encoding) overload, I don't know. But
there are other overloads for the StreamWriter constructor that take a
file name and an encoding. For example:

http://msdn2.microsoft.com/en-us/library/f5f5x7kt.aspx

Pete
Dec 8 '07 #5

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

Similar topics

1
by: dmiller23462 | last post by:
Hi again guys.... This is my first source of help, by far the best ASP intellectual collective....Thanks in advance for any assistance...Anyway.... The forms I'm still working on (finishing...
8
by: timtos | last post by:
I want to save text in a file and after that I want to display this textfile using the internet explorer. If I am displaying "html text" everything is fine but if I want to display plain text...
3
by: ZoombyWoof | last post by:
Hi all. I have a c# app that sometimes writes to a textfile. Sometimes the text contains the swedish letters åäö. In the app these letters look ok, but when StreamWriter has written them to the...
4
by: Jaroslav Jakes | last post by:
Hi, please help. Sounds so simple. We receive textfiles (customer orders) as e-mail attachment. These textfiles contain a simple structure of orders, like: custno, itemno, qty, text Since...
4
by: Yves Royer | last post by:
Hi all, i'm currently writing an application which can read multiple formats of textfiles and converts all of those to another one and the same. One of the incoming type of textfiles are written...
4
by: Nick | last post by:
Hi, I am trying to output a string of chinese characters as a text file. When I open a file for writing from VB, the file is automatically set to UTF-8 encoding (can tell by opening the file...
7
by: MrNobody | last post by:
I am having alot of difficulty with text files in .NET when they have special characters like í, ó, ç etc... When i read a text file with them and then write it back out it ignores all of...
1
by: ujjwaltrivedi | last post by:
Hey guys, Can anyone tell me how to create a text file with Unicode Encoding. In am using FileStream Finalfile = new FileStream("finalfile.txt", FileMode.Append, FileAccess.Write); ...
3
by: SteveB | last post by:
I have posted this question in the Visual Basic 2005 and Visual Basic .Net 2005 discussion groups, also. Hi. I am developing an application/web page with VB.Net that will populate a SQL...
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: 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:
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
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
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
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.