none
[VB2005]write a file RRS feed

  • Question

  • Hi,
    I need to write a string composed by some characters using the function CHR(int). Give a look to the code:

    Using sw As StreamWriter = New StreamWriter(c:\file.dat", True, Enc.ASCII)

           Mystr =  "0000148" & Chr(255) & Chr(255) & Chr(235) & Chr(127) & "Sample"
           sw.Write(Mystr)
            sw.Close()
    End Using


    What the program writes into the file is:
    {0000148???
    in hex
    7B 30 30 30 30 31 34 38 3f 3f 3f 7f  
    instead it must be..........38 ff  ff ff  7f
    I think the why is due to a different charachters encoding.
    Could you help me?
    Tuesday, July 10, 2007 6:19 PM