MemoryStream et StreamWriter, defaut endocage ?
bonjour à tous..
voici un petit bout de code qui me pose problème
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
MemoryStream MS = new System.IO.MemoryStream();
using (StreamWriter sw = new StreamWriter(MS, Encoding.UTF8))
{
sw.Write("toto");
sw.Close();
}
MemoryStream testMS = new MemoryStream(MS.GetBuffer(), 0, MS.GetBuffer().Length);
FileStream outStream = File.OpenWrite("c:\\again.txt");
testMS.WriteTo(outStream);
outStream.Flush();
outStream.Close(); |
quand j'ouvre le fichier again.txt avec notepad je vois toto et il y a une suite de caractère invisible
mais quand j'ouvre le fichier avec notepad++
j'obtiens toto et une suite de NUL dans un carré noir.. j'ai aucune idée du problème, et je bloque bien dessus.. merci de votre aide
http://img834.imageshack.us/img834/7357/encodage.jpg