德尔福。 SynEdit - 加载文件的最后 500 KB
请给我建议一些东西。
如果文件的最后 500 KB 超过 500 KB,如何将其加载到 UniSynEdit/SynEdit 中?
谢谢!!!
Please suggest me something.
How can I load into UniSynEdit/SynEdit last 500 KB of file if it is more then 500 KB?
Thanks!!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以选择的一种选择是将文件的最后 500 KB 复制到临时文件中,然后要求 synEdit 处理该临时文件。
One option you have is to copy the last 500 KB of the file into a temporary file and then ask synEdit to process the temporary file.
创建一个
TFileStream
并查找要从中加载的位置,然后将流传递到编辑控件。它应该从当前位置加载。请注意,如果文件被编码为 UTF-8 或其他每个字符使用可变字节数的编码,则跳转到文件中的任意位置是不安全的。您可能会跳转到表示两字节序列后半部分的字节,然后您读取的所有后续字符都可能被错误解释。 ANSI 和 UTF-16 文件没有这种危险。
Create a
TFileStream
and seek to the position you want to load from, and then pass the stream to the edit control. It should load from the current position.Beware that if the file is encoded as UTF-8 or something else that uses a variable number of bytes per character, it isn't safe to jump to arbitrary positions in the file. You might jump to a byte that represents the second half of a two-byte sequence, and then all the subsequent characters you read could be interpreted incorrectly. ANSI and UTF-16 files don't have that danger.