Solved

vb.net writing textfiles

Posted on 2004-09-30
7
861 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 70

Expert Comment

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

Author Comment

by:bear23
ID: 12191072
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 70

Expert Comment

by:Éric Moreau
ID: 12191105
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:bear23
ID: 12193678
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
ID: 12193696
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 70

Expert Comment

by:Éric Moreau
ID: 12193734
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
ID: 12194284
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

777 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