Results 1 to 2 of 2

Thread: [help]

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2015
    Posts
    3

    [help]

    hi guy I'm trying to load the strings of hex output of a file to a textbox.

    here is an example:




    what im trying do is convert the bytes from the hexbox to the ASCIIbox when i open a file.

    i can can load the hex values but not the strings and i need to load them as it wont be a hex editor with out them


    or maybe you can help me convert this code to work for ASCII

    Code:
    	TextBox2.Text = String.Join(" ", IO.File.ReadAllBytes(OpenFileDialog1.FileName).Select(Function(B)/> b.ToString("X2")).ToArray()) '//working to show bytes
    thanks in advance

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,930

    Re: [help]

    This part of your code reads the file (as you want to display it):
    Code:
    IO.File.ReadAllBytes(OpenFileDialog1.FileName)
    You could write another line to use that, but it would be more efficient to combine the two, so that they both use the same data read, eg:

    Code:
    	TextBoxAscii.Text = IO.File.ReadAllBytes(OpenFileDialog1.FileName)
    	TextBox2.Text = String.Join(" ", TextBoxAscii.Text.Select(Function(B)/> b.ToString("X2")).ToArray())

    edit: oops... now I'm thinking that TextBoxAscii would need a bit more work to display it, and that a simple .ToString wont do it. unfortunately I'm out of time, so hopefully somebody else will correct it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width