Txt files
Txt files
Txt files
Txt files
Txt files
Txt files Txt files Txt files Txt files Txt files Txt files Txt files Txt files
Txt files Txt files
Txt files
Go Back  Xtreme Visual Basic Talk > > > Txt files


Reply
 
Thread Tools Display Modes
  #1  
Old 09-28-2010, 07:44 PM
letrstotheprez's Avatar
letrstotheprez letrstotheprez is offline
Newcomer
 
Join Date: Sep 2010
Posts: 17
Default Txt files


I tried opening a .txt file in a multiline text box but textbox.loadfile doesn't work. So then I tried opening it in a richtextbox but then it says the file type isn't supported. So basically how do I create and open .txt files and if I wanted to create multiple file types (.html, etc) then what would be the best way to do that? I am making a multitabbed text editor.
Reply With Quote
  #2  
Old 09-29-2010, 12:26 AM
gamernixin's Avatar
gamernixin gamernixin is offline
Regular
 
Join Date: Nov 2006
Posts: 89
Default

__________________
If you don't post the fix for your problem, then you are completely missing the point of online support forums.
- Signature by Chrisace, and i couldn't agree more !
Reply With Quote
  #3  
Old 09-29-2010, 10:10 AM
AtmaWeapon's Avatar
AtmaWeaponTxt files AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

From what I have observed (and also read in the documentation) the RichTextBox assumes that what you give it in LoadFile() is RTF text. Thus, you can't use that overload to load plain ASCII. However, there is an overload that takes a RichTextBoxStreamType parameter that lets you specify that your file is just plain old text. I tested this out and it works fine with ASCII and UTF-8 but did the wrong thing for other Unicode formats.

Or, you can load the text using file I/O and set the Text property; this works for both the rich text box and the normal one:
Code:
Dim fileContents As String = System.IO.File.ReadAllText(fileName)
txtText.Text = fileContents
This gives you more freedom to choose encodings and doesn't have any silly assumptions about the format of your text.
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #4  
Old 09-29-2010, 02:43 PM
letrstotheprez's Avatar
letrstotheprez letrstotheprez is offline
Newcomer
 
Join Date: Sep 2010
Posts: 17
Default

Thank you very much that helped a lot
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Txt files
Txt files
Txt files Txt files
Txt files
Txt files
Txt files Txt files Txt files Txt files Txt files Txt files Txt files
Txt files
Txt files
 
Txt files
Txt files
 
-->