Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi, everyone
my ques Is..

How to read last 100 bytes of hex from file using vb.net 2012
and then insert it into the textbox ..
so far i have given below given code but did'nt get output to textbox
Dim fs as new filestream(filepath,filemode.opem,fileaccess.readwrite)
fs.seek(100,seekorigin.end)
dim bytearray(100) as byte
dim numbytesread as integer=fs.read(bytearray,0,100)
textbox1.text=fs.tostring 


i want last 100 bytes to textbox
thnxxxs in advance
Posted

1 solution

You should try something similar to:
VB
Dim fs As New FileStream(filepath, FileMode.Open, FileAccess.Read)
fs.Seek(-100, SeekOrigin.End)
Dim bytearray(100) As Byte
Dim numbytesread As Integer = fs.Read(bytearray, 0, 100)

textbox1.text = System.Text.Encoding.ASCII.GetString(bytearray)
 
Share this answer
 
Comments
Member 10521418 28-May-15 9:11am    
sry but it is ascii but idont want this i want hexdump of the file last 100 hex bytes...
Sergey Alexandrovich Kryukov 28-May-15 11:21am    
All right, just ignore the last line.
You asked about 100 bytes, you got your 100 bytes, then do whatever you want with them.
Cannot do the hex dump? Too bad. Then ask a separate question about hex dump. And accept formally this answer; it is complete.
—SA
Member 10521418 28-May-15 11:54am    
thxxxs but i have completed by my own .... but thanks guys for rply ....
Sergey Alexandrovich Kryukov 28-May-15 11:59am    
It's not "but". Everything to be "completed" is beyond the scope of your question. Your question is answered in full, so I suggest you accept it formally.
—SA
Member 10521418 28-May-15 12:25pm    
hmmmmm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900