Textbox encoding ?

bzz

New member
Joined
Feb 18, 2008
Messages
2
Programming Experience
5-10
I am trying to create a custom notepad-like application, for personal usage in VB.NET. One of my main concerns is loading .exe and other 'strange' file types as normal notepad does..

Example:

Opening a shortcut to notepad.exe in notepad yields results like this:

VB.NET:
L        À      FŸ       à`‘zÄš¼.®õÈ à`‘zÄ                     ó  PàOÐ ê:i¢Ø +00 /C:\                   < 1     [7Ñ„ WINDOWS &   ï¾Y7ÔV[7ÖŒ   W I N D O W S    @ 1     [7ò„ system32  (   ï¾Y7ÔV[7   s y s t e m 3 2    H 2   1 `  notepad.exe .   ï¾1 `[7=‡   n o t e p a d . e x e      U            4       T         :Xm¤   Primary C:\WINDOWS\system32\notepad.exe  ) @ % S y s t e m R o o t % \ s y s t e m 3 2 \ s h e l l 3 2 . d l l , - 2 2 5 6 3 + . . \ . . \ . . \ . . \ . . \ W I N D O W S \ s y s t e m 3 2 \ n o t e p a d . e x e  % H O M E D R I V E % % H O M E P A T H %      %SystemRoot%\system32\notepad.exe

While opening it in my app looks like this:

VB.NET:
L

I'm using a basic IO.StreamReader call to load the files... I tried different encodings and using a rich textbox, but nothing seems to work. I WANT to see all that garbage. :)

Any help?
 
mmm.. I worked this out late last night and it seems to be what I want.. just have to go through and tidy up a bit. :) Any better suggestions? This method seems to load a ~6mb file in 5-6 seconds... which is nice.

VB.NET:
    Public Sub LoadBytes(ByVal TextBox As RichTextBox, ByVal FileName As String)

        Dim objStreamRead As IO.StreamReader
        Dim inputString As String
        Dim ArrayHold() As Byte
        objStreamRead = New IO.StreamReader(FileName, System.Text.Encoding.Default)
        inputstring = objStreamRead.ReadToEnd()
        objStreamRead.Close()
        arrayhold = Encoding.Default.GetBytes(inputstring)
        TextBox.Clear()


        Dim Index As Integer = 0
        Dim Str As New StringBuilder
        Dim tStr As String = ""
        Dim tempStr As String = ""
        Dim IndexEnd As Integer = 0

        Do
            IndexEnd = Index + 9
            For x As Integer = Index To IndexEnd
                If Not x > UBound(arrayhold) Then
                    If arrayhold(x) < 32 Then
                        Select Case arrayhold(x)
                            Case 10
                                tempStr &= vbCrLf
                            Case 13

                            Case Else

                        End Select
                    Else
                        tempStr &= Chr(arrayhold(x))
                    End If
                End If
            Next
            Str.Append(tempStr)
            tempStr = ""
            Index += 10
        Loop While IndexEnd < UBound(arrayhold)
        TextBox.Text = Str.ToString

    End Sub
 
Back
Top