write string into file

  • Thread starter Thread starter Romain TAILLANDIER
  • Start date Start date
R

Romain TAILLANDIER

Hi group,

I try to write a string into a file. But every fonction for file use byte
array.
Is there methode to write string into file ?
if not, is there methode to cast string into byte array ??

thanks for help !
ROM
 
Romain TAILLANDIER said:
I try to write a string into a file. But every fonction for file use byte
array.
Is there methode to write string into file ?
if not, is there methode to cast string into byte array ??

Are you writing a file which *only* has text? If so, look at
StreamWriter, File.OpenText etc. If you're writing a file with mixed
text and binary data, have a look at BinaryWriter.

Finally, for converting between strings and byte arrays, read
http://www.pobox.com/~skeet/csharp/unicode.html
 
rom,
you can use System.Text.UnicodeEncoding.Unicode.GetBytes("my string")
to convert string to byte array
 
Hi!

Encoding class's GetBytes method can be used to convert a string to byte
array. Ofcourse, make sure you use the right "type" of Encoding class
(ASCII, UTF7, etc).

Regards,
Kumar Gaurav Khanna

--
----------------------------------------------------------------------------
-------
I can't be garbage collected; I am pinned to .NET
----------------------------------------------------------------------------
-------
Microsoft MVP - .NET
WinToolZone - http://www.wintoolzone.com/
Spelunking Microsoft Technologies and my home on the web :-)
OpSupport - Spelunking Rotor
http://opsupport.sscli.net/

http://dot-net.blogspot.com/
http://kgk.blogspot.com/
 
Back
Top