473,387 Members | 1,925 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,387 software developers and data experts.

About FileStream and StreamWriter!?

About FileStream and StreamWriter!?

I have a string1 which contains(of course in unicode) a html code with
Unicode charset specified in it.

1)

byte[]content= System.Text.UnicodeEncoding.Unicode.GetBytes(strin g1);

System.IO.FileStream wr=new System.IO.FileStream("C:\\myhtml.html"
,System.IO.FileMode.CreateNew);

wr.Write(content,0,content.Length);

wr.Close();

When I opened the file some characters are unreadable, so something is wrong
in my code above, but then I have done:

2)

byte[]content= System.Text.UnicodeEncoding.Unicode.GetBytes(strin g1);

//System.IO.FileStream wr=new //System.IO.FileStream("C:\\myhtml.html"
,System.IO.FileMode.CreateNew);

//wr.Write(content,0,content.Length);

//wr.Close();

System.IO.StreamWriter tr=new System.IO.StreamWriter("C:\\myhtml.html"
,,false,System.Text.Encoding.Unicode);

string teststr=System.Text.Encoding.Unicode.GetString(con tent);

tr.Write(teststr);//(I did not simply used string1 in it because of reason
of testing)

And file was in good form, why first time wasn't good as second?

Tanks to all!

Nov 22 '05 #1
0 852

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

Similar topics

1
by: Viorel | last post by:
About FileStream and StreamWriter!? I have a string1 which contains(of course in unicode) a html code with Unicode charset specified in it. 1) bytecontent=...
2
by: Kai Bohli | last post by:
Hi all ! This is my first day with Visual Studio and C#, and I'm trying to send "raw data" to the printer port. I found the SendFileToPrinter example below in a knowledge base at MS site It...
4
by: Dan | last post by:
In the following example, is it necessary to close the FileStream object as well as the StreamWriter object? FileStream fs = new FileStream(fileName, FileMode.CreateNew, FileAccess.Write,...
5
by: Patrick Sannes | last post by:
Hi, At this moment I have one large sourcecode file and want to seperate it into multiple files. When I do so, the app crash after he created 6389 (156794880 bytes total) source files with the...
4
by: John Salerno | last post by:
In Murach's C#, it shows that StreamWriter and StreamReader both take a stream object as a parameter, and the book's examples of these two classes all first create a FileStream object. But I notice...
3
by: sbparsons | last post by:
I have a file opened as a FileStream. I have a StreamReader and StreamWriter object opened, referencing the FileStream object. My aim is to read lines from the file until I find the line where...
0
by: ÀÏÓà | last post by:
i just use the following simple code for test, when the code line run to flush()/close(),the simple web process will often down ! i check the web server event log ,the "sc-status sc-substatus...
1
by: iwdu15 | last post by:
hi...just a quick question. what are the differences in using a FileStream and StreamWriter opposed to just a StreamWriter.....for instance Dim fs as New FileStream("C:\Test.txt",...) Dim sw As...
4
by: khan | last post by:
Hi guys I see blue line underneat the word FileStream in the following code in line 2. Can any one help me to find out what am I missing Imports System.IO Imports System.Windows.Forms Public...
2
by: Eric | last post by:
Hi, i'm experientating with object StreamWriter in asp.net. This code works: the string is written to an excel sheet, but i have a questions about it: how does asp.net know the string must be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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...

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.