从exe文件中读取最后100个字节 [英] read last 100 bytes from exe file

查看:83
本文介绍了从exe文件中读取最后100个字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

m使用此代码从文件中获取字节...

hi guys,
m using this code for getting bytes from file ...

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)



-----------------------

在阅读任何文本文件时面对的是什么,它工作正常,但当我读取一个exe文件时,它读取100个字节,但不是从最后但实际上它正在阅读上面的几条最后一行,所以由此没有得到最后几行......我现在不是那个prome ....



需要帮助..

thnxxs提前...


-----------------------
the prome what m facing is while reading to any text file it works fine but when i read an exe file it read 100 bytes but not from last but actualy it is reading above of few last lines , so by this m not getting last few lines ... i dont now wht was the prome ....

help needed ..
thnxxs in advance ...

推荐答案

是的,它是......它只是在EXE文件不是可打印的。



EXE文件是二进制文件,而不是文本 - 所以它们包含很多超出ASCII可打印集的值:这些是映射到控制代码(控制数据在某些设备上的显示方式),以及涉及严格ASCII的大量无效值。

这不是导致问题的读数,而是显示!使用调试器并检查bytearray的内容,你会看到所有的值。



但是......试图将二进制文件的结束显示为任何文本形式可能是一个相当愚蠢的形式 - 你实际上想用这个来实现什么?
Yes, it is...it's just that what is in the EXE file is not that printable.

EXE files are binary, not text - so they contain a lot of values which are outside the ASCII "printable" set: some of these are "mapped to control codes (which control how data is displayed on some devices), and a larger number of "invalid" values as far as strict ASCII is concerned.
It's not the read that is causing the problem, it's the display! Use the debugger and examine the content of bytearray and you will see all of the values.

But...trying to display the "end" of binary files as any form of text is probably a fairly silly one - what are you actually trying to achieve with this?


这篇关于从exe文件中读取最后100个字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆