Hey I have made a HEX editor But im having one problem when I open A large file like 150KB Or over it takes a hour to load and if anything clicked it freezez is there any way to speed this up here is my OpenFileDialog code... And if I open the save one file with HxD (Different HEX editor) then Save it with mine some coding is different It only works when I save it with HxD does anyone know why?
Here is my Openfiledialog
Code:Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click If Me.OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then Me.TextBox1.Text = String.Empty Using streamReader As New IO.StreamReader(OpenFileDialog1.FileName, System.Text.Encoding.Default, True) Array.ForEach(Array.ConvertAll(streamReader.ReadToEnd.ToArray, _ New Converter(Of Char, String)(Function(x As Char) Hex(AscW(x)).PadLeft(2, "0"c) & " ")), AddressOf Me.TextBox3.AppendText) End Using End If End Sub
Here is my savefiledialog
Code:Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TextBox3.Text = TextBox3.Text.Replace(" ", "") Dim SaveFileDialog1 As New SaveFileDialog Dim sw As System.IO.StreamWriter With SaveFileDialog1 .Filter = "Text files (*.txt)|*.txt|" & "All files|*.*" If .ShowDialog() = DialogResult.OK Then sw = New System.IO.StreamWriter(.FileName) sw.Write(HexToString(TextBox3.Text)) sw.Close() sw.Dispose() End If SaveFileDialog1.Dispose() End With End Sub Function StringToHex(ByVal text As String) As String Dim hex As String = "" For i As Integer = 0 To text.Length - 1 hex &= Asc(text.Substring(i, 1)).ToString("x").ToUpper Next Return hex End Function Function HexToString(ByVal hex As String) As String Dim text As New System.Text.StringBuilder(hex.Length \ 2) For i As Integer = 0 To hex.Length - 2 Step 2 text.Append(Chr(Convert.ToByte(hex.Substring(i, 2), 16))) Next Return text.ToString End Function




Reply With Quote