Richtextbox问题 [英] Problem with richtextbox

查看:81
本文介绍了Richtextbox问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Richtextbox来显示不同的* .rtf文件.通常,这很好.但是有些文件很奇怪 问题出现了.当将它们加载到RichTextBox中时,会出现错误5无效的文件格式". (原始消息以德语显示,也许原始英语消息会有所不同.

i am using a richtextbox for displaying different *.rtf files. Normally this is working just fine. But with some files a strange problem is arising. When loading them into the richtextbox there is Error 5 "invalid file format" (the original message is shown in german language, maybe the original english message would be slightly different.

当查看rtf文件时(即通过将其加载到记事本中),它看起来确实像是一种绝对奇怪的编码.某物 像

When looking into the rtf file (i.e by loading it into the notepad) it really seems like an absolutely strange encoding. Something like

  _ _ _ [Content_Types] .xml¢_(D¾V‰¡‡ªª__ú8¶H¥`ìXõKöòúûnDUA*å_)YïÌììăÑÚšl1iïJÖ/z,_'½ÒnV² »ÆoR€"wàͳÌIÊŠ〜‰‰__ 8›ïWòZè" V0}¿〜ûßÀ» „´ù>þÁŒýuQwH oî·á_ ÿÿ_PK___ _††ßaÈ}7ÛÒÙÞH¡w"ë_„™ì_w_̤ھ½£PÛ^æôçËO›››;§§<__AYÕØ›`Gßkxm

"PK___ _ _ ! Ýü•7f_  _ _[Content_Types].xml ¢_(D¾V‰¡‡ªª__ú8¶H¥­`ìXõKöòúûnDUA*å_)YïÌììăÑÚšl 1iïJÖ/z,_'½ÒnV²ÉK~ϲ„Â)a¼ƒ’m ±Ñúj0Ù_H_u»T²9bxà<É9X‘­ÀQ¥òѤ×k®’‰_Œ–I)_:õƒ%ß1_ÔÙœIs ÒÉ`üC]9N°ë{#k¢VEÄWaI__ù¨¸òrai†¢_æ€N_UZBÛ_£…è%¤Dž[S´_+´Ûë?ª#áÆ@ú_[Ü.zÒ9Ž>$N{9›­êÍ+P9Y_ ¢†vuÇGD²ì_ÃÆoR€"wàͳÌIÊŠ~‰‰˜_8›ïWòZè""V0}¿˜ûßÀ»„´ù">þÁŒýuQw­H oî·á_ ÿÿ_ PK___ _ †ïßaÈ}7Û "ÒÙÞH¡w"ë_„™ì_w_̤ھ½£PÛ^æôçËOÖ›ƒ›Ô;§<_¯aYÕ Ø›`Gßkxm.....

通常rtf文件如下所示:(带有德语文本)

Doch hat er den Schl \'fc sselbegriff vergessen,den man daf \' fcr nennen muss:"A ...,A ...,A ...". Leider战争达赖斯死了...

{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch31506\stshfloch31506\stshfhich31506\stshfbi31507\deflang1031\deflangfe1031\themelang1031\themelangfe0\themelangcs0{\fonttbl{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f34\fbidi \froman\fcharset1\fprq2{\rtlch\fcs1 \af0\afs16 \ltrch\fcs0 \f40\fs16\cf17\lang1031\langfe1031\langfenp1031\insrsid10234110\charrsid10234110 Eine Begebenheit aus der guten alten Zeit, also den achtziger Jahren: Auf dem M\'fcnchner Flughafen, der damals noch keine Tagesreise von M\'fcnchen entfernt war, kommt ein Mann an, der offenkundig Asyl beantragen will. Doch hat er den Schl\'fc sselbegriff vergessen, den man daf\'fcr nennen muss: "A..., A..., A...". Leider war damals die .....

我尝试使用以下代码将一个奇怪的rtf文件打开到文本框中(通常适用于所有类型的文件)

          

           Dim ecode As Encoding = Encoding.UTF7

                  bTXT = IO.File.ReadAllBytes(sViewFile)
           textbox.text = ecode.GetString(bTXT)

            bTXT = IO.File.ReadAllBytes(sViewFile)
            textbox.text = ecode.GetString(bTXT)

但即使在 尝试所有现有的 代码页(很多),根本没有一个代码页可以正常工作.最奇怪的事情:当我尝试使用MSWord或旧的写字板打开奇怪的rtf文件时,它们看起来绝对是正常的.

but even after trying all existing Codepages (which are quite a lot) there was not one Codepage which worked at all. the strangest thing: When i try to open the strange rtf-files with MSWord or old WordPad they look absolutely normal.

有人知道这个* rtf文件有什么问题吗? 任何想法我都能够使它们在richtextbox?

Does anybody know what is ‘wrong’ with this *rtf files ?  Any idea how I could be able to make them readable inside an richtextbox ?

非常感谢您的任何答复

迈克尔·霍本(Michael Houben)

推荐答案

但是对于某些文件,会出现一个奇怪的问题.将它们加载到RichTextBox中时,会出现错误5无效的文件格式"

文件已压缩. RTF文件应为纯文本,并按照您的示例显示RTF代码序列.您正在查看的文件不是纯文本,也不会作为RTF处理.您应该回到找到文件的位置,然后 查看您需要使用它做什么,例如将其解压缩以访问RTF内容(如果确实如此).

The files are compressed.  A RTF file should be plain text, with RTF code sequences as per your example.  The file that you're looking at is not plain text, and will not process as RTF.  You should go back to wherever you found the file and see what you need to do with it, for instance unzipping it, to get access to the RTF content (if that's what it really is).


这篇关于Richtextbox问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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