StreamWriter problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • fniles

    #1

    StreamWriter problem

    I am using VB.NET 2005 and streamWriter to write to a file.
    Before writing to the file, I encrypt the string.
    StreamWriter does not write it correctly to the file, I have to change to
    FileOpen, Print and FileClose to write it correctly to a file.
    StreamWriter will write something like:
    ÃzÃ,Ãz¬±°± ¸Â²Â¬Ã,±°°² ¬ÃSáòöéóà ¼Â
    instead of
    ÞÂÞ¬±°±¸²¬Â±°°² ¬Êáòöéóü

    Why does StreamWriter write it incorrectly ? Can I write those ascii
    characters using StreamWriter ?
    Thank you.

    Dim swFile As StreamWriter

    Crypt(Account1)
    swFile = New streamWriter("c :\test.HTM", False)
    swFile.Write(re )
    swFile.Close()

    Public Function Crypt(ByVal Text As String) As String
    Dim strTempChar As String
    Dim I As Int16

    For I = 1 To Len(Text)
    strTempChar = Asc(Mid$(Text, I, 1)) + {some number}
    Mid$(Text, I, 1) = Chr(strTempChar )
    Next I
    Crypt = Text


  • Herfried K. Wagner [MVP]

    #2
    Re: StreamWriter problem

    "fniles" <fniles@pfmail. comschrieb:
    >I am using VB.NET 2005 and streamWriter to write to a file.
    Before writing to the file, I encrypt the string.
    StreamWriter does not write it correctly to the file, I have to change to
    FileOpen, Print and FileClose to write it correctly to a file.
    StreamWriter will write something like:
    ÃzÃ,Ãz¬±°± ¸Â²Â¬Ã,±°°² ¬ÃSáòöéóà ¼Â
    instead of
    ÞÂÞ¬±°±¸²¬Â±°°² ¬Êáòöéóü
    >
    Why does StreamWriter write it incorrectly ? Can I write those ascii
    characters using StreamWriter ?
    'StreamWriter' uses the UTF-8 encoding by default. Maybe the application
    you are using to view the file assumes or expects another encoding. The
    'StreamWriter' class' constructor is overloaded---one overload expects a
    'System.Text.En coding' object.

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

    Comment

    • Harry

      #3
      Re: StreamWriter problem

      "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.atwrot e in message
      news:ejojNhLIIH A.5544@TK2MSFTN GP02.phx.gbl...
      "fniles" <fniles@pfmail. comschrieb:
      >>I am using VB.NET 2005 and streamWriter to write to a file.
      >Before writing to the file, I encrypt the string.
      >StreamWriter does not write it correctly to the file, I have to change to
      >FileOpen, Print and FileClose to write it correctly to a file.
      >StreamWriter will write something like:
      >ÃzÃ,Ãz¬±°± ¸²¬Ã,±°° ²Â¬ÃSáòöéó ü
      >instead of
      >ÞÂÞ¬±°±¸²¬Â±°° ²¬Êáòöéóü
      >>
      >Why does StreamWriter write it incorrectly ? Can I write those ascii
      >characters using StreamWriter ?
      >
      'StreamWriter' uses the UTF-8 encoding by default. Maybe the application
      you are using to view the file assumes or expects another encoding. The
      'StreamWriter' class' constructor is overloaded---one overload expects a
      'System.Text.En coding' object.
      >
      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
      You are the man, Herfried! Just another reason why VB 2005 is so cool... The
      language requires considerable study. I have found that I was not able to
      beat it into the VB6 shape (grin). Consequently, my coding has improved
      hugely.

      Herfried, while on the subject of VS 2005, what are your observations of VS
      2008?


      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: StreamWriter problem

        "Harry" <someone@micros oft.com.auschri eb:
        Herfried, while on the subject of VS 2005, what are your observations of
        VS 2008?
        Unfortunately I didn't yet have the opportunity to work with VS 2008 :-/.

        --
        M S Herfried K. Wagner
        M V P <URL:http://dotnet.mvps.org/>
        V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

        Comment

        Working...