¿Cómo cambiar codificación de un streamwriter?

D

Diego F.

Hola. Tengo este trozo de código:

If File.Exists(Ls_NombreFichero) = False Then
sw = File.CreateText(Ls_NombreFichero)
Else
sw = File.AppendText(Ls_NombreFichero)
End If

El caso es que necesito cambiar la codificación, porque el Encoding por
defecto es utf-8 y quiero probar otro. ¿Cómo lo hago? La propiedad encoding
del streamwriter es sólo lectura, y no sé cómo usar un constructor que me
cuadre.
 
J

Jan Hyde (VB MVP)

"Diego F." <[email protected]>'s wild thoughts were
released on Mon, 12 Nov 2007 12:19:25 +0100 bearing the
following fruit:
Hola. Tengo este trozo de código:

If File.Exists(Ls_NombreFichero) = False Then
sw = File.CreateText(Ls_NombreFichero)
Else
sw = File.AppendText(Ls_NombreFichero)
End If

El caso es que necesito cambiar la codificación, porque el Encoding por
defecto es utf-8 y quiero probar otro. ¿Cómo lo hago? La propiedad encoding
del streamwriter es sólo lectura, y no sé cómo usar un constructor que me
cuadre.

You are correct, appendtext does append UTF-8 encoded text
however if you create your own streamwriter you should be
able to specify the encoding you want
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top