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

StreamWriter problem

Hi, I'm trying to make a chat program, but it seems to have some kind
of problem with the some characters. To be more precise, the only
characters giving me problem are "{" and "}".
When I try to send them with
stream.Write(A,0,A.Length);
where A is a String
it tells me that there is a incorrect character.
Any help?

Aug 16 '06 #1
2 1223

zon7 wrote:
Hi, I'm trying to make a chat program, but it seems to have some kind
of problem with the some characters. To be more precise, the only
characters giving me problem are "{" and "}".
When I try to send them with
stream.Write(A,0,A.Length);
where A is a String
it tells me that there is a incorrect character.
Any help?
There isn't an overloaded method for StreamWriter.Write that takes the
string to be written, start index, and length. The method you are
trying to call is Write (string, object, object) as described here
http://msdn2.microsoft.com/en-us/library/fd857wct.aspx.

If you want to write the string as an array of chars then you could use
this call:

stream.Write (A.ToCharArray (), 0, A.ToCharArray ().Length);

Or if you just want to write the string then call:

stream.Write (A);

Let me know if this helps,

Nick
http://seecharp.blogspot.com/

Aug 16 '06 #2
zon7 <zo******@gmail.comwrote:
Hi, I'm trying to make a chat program, but it seems to have some kind
of problem with the some characters. To be more precise, the only
characters giving me problem are "{" and "}".
When I try to send them with
stream.Write(A,0,A.Length);
where A is a String
it tells me that there is a incorrect character.
Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Aug 16 '06 #3

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: 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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
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,...

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.