byte[] to string

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

    byte[] to string

    Hi ALL.
    Someone knows how can I convert a byte[] field to a string field?
    The problem is, I'm uploading a xml file and I'm requesting the file using
    Request.BinaryR ead();

    So, now I need to convert the result of Request.BinaryR ead() method to a
    string variable.

    Thanks in advance.

    FernandoLopes


  • oj

    #2
    Re: byte[] to string

    You can take a look at ASCIIEncoding.G etString() method.

    --
    -oj


    "Fernando Lopes" <fernandomattar lopes@[remove]msn.com> wrote in message
    news:%23qLes7pG FHA.3648@TK2MSF TNGP09.phx.gbl. ..[color=blue]
    > Hi ALL.
    > Someone knows how can I convert a byte[] field to a string field?
    > The problem is, I'm uploading a xml file and I'm requesting the file using
    > Request.BinaryR ead();
    >
    > So, now I need to convert the result of Request.BinaryR ead() method to a
    > string variable.
    >
    > Thanks in advance.
    >
    > FernandoLopes
    >
    >[/color]


    Comment

    • Jon Skeet [C# MVP]

      #3
      Re: byte[] to string

      Fernando Lopes <fernandomattar lopes@[remove]msn.com> wrote:[color=blue]
      > Someone knows how can I convert a byte[] field to a string field?[/color]

      Use Encoding.GetStr ing.

      You need to know what encoding the binary data is in though.
      See http://www.pobox.com/~skeet/csharp/unicode.html

      --
      Jon Skeet - <skeet@pobox.co m>
      Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

      If replying to the group, please do not mail me too

      Comment

      • Fernando Lopes

        #4
        Re: byte[] to string

        Thanks for all!

        Fernando

        "Jon Skeet [C# MVP]" <skeet@pobox.co m> wrote in message
        news:MPG.1c882f 9d88ac81f198bdc 4@msnews.micros oft.com...[color=blue]
        > Fernando Lopes <fernandomattar lopes@[remove]msn.com> wrote:[color=green]
        > > Someone knows how can I convert a byte[] field to a string field?[/color]
        >
        > Use Encoding.GetStr ing.
        >
        > You need to know what encoding the binary data is in though.
        > See http://www.pobox.com/~skeet/csharp/unicode.html
        >
        > --
        > Jon Skeet - <skeet@pobox.co m>
        > http://www.pobox.com/~skeet
        > If replying to the group, please do not mail me too[/color]


        Comment

        • DalePres

          #5
          Re: byte[] to string

          If you're going to be transporting your string over the web you should
          probably convert your bytes to a Base64 string using
          Convert.ToBase6 4String(byte []) and then get the bytes back on the other end
          using Conver.FromBase 64String(string ).

          HTH

          DalePres

          "Fernando Lopes" <fernandomattar lopes@[remove]msn.com> wrote in message
          news:%23qLes7pG FHA.3648@TK2MSF TNGP09.phx.gbl. ..[color=blue]
          > Hi ALL.
          > Someone knows how can I convert a byte[] field to a string field?
          > The problem is, I'm uploading a xml file and I'm requesting the file using
          > Request.BinaryR ead();
          >
          > So, now I need to convert the result of Request.BinaryR ead() method to a
          > string variable.
          >
          > Thanks in advance.
          >
          > FernandoLopes
          >
          >[/color]


          Comment

          Working...