Solved

vb.net writing textfiles

Posted on 2004-09-30
7
860 Views
Last Modified: 2010-08-05
I have a vb.net program that is using the streamwriter to take data and manipulate it. My problem is when I use wordpad to open the file it places these wierd characters through out it. Now if I open it on a pc using word it is ok. If I open the file using wordperfect it is ok. So what am I doing wrong when using the streamwriter to do something like that.

For not the data I am grabbing is coming off an oracle database I am reading the oracle database and then dumping to a dataset and read line by line and manipulating the data.







0
Comment
Question by:bear23
  • 3
  • 3
7 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
Save the file as a txt file (instead of a rich text file)
0
 

Author Comment

by:bear23
Comment Utility
I did, the only thing I can think of is it is grabbing something out of oracle. The thing is in notepad and reading it in vb.net it is fine.




0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
When you open it in WordPad or WordPerfect, your file is transformed (unless you tell to save is as a text file).

So use NotePad (which does not transform your file) or be very cautious when you save your file.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:bear23
Comment Utility
ok, but how do you do that with the streamwriter I am using


this is what I have to create the file:



Dim createFile As IO.StreamWriter
createFile = New System.IO.StreamWriter("c:\datafile.txt", True)
0
 

Author Comment

by:bear23
Comment Utility
I did in fact open the file manually with notepad and then saved it in notepad. Then opened it with wordperfect and it was ok. How can I fix the problem with the streamwriter

0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
Notepad will not affect the content. WordPad and WordPerfect will. So do not open the file into these tools (or be sure to save them as plain text file).

If you do this, you will not have any problem reading them using the streamreader.

==============================================================

Where is the problem exactly? Reading the file after opening it in WordPerfect? Can you bypass WordPerfect? What are you using to read the file (surely not a streamWRITER - maybe a streamREADER)?
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 35 total points
Comment Utility
What do the characters look like?  Are they Unicode?  You can using Unicode encoding with the StreamWriter:

Dim sw As StreamWriter = New StreamWriter(path, System.Text.Encoding.Unicode)

Bob
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now