By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,651 Members | 1,757 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,651 IT Pros & Developers. It's quick & easy.

Save the file in Wordpad not in Notepad using VB.net

P: n/a
Hey, there!

I'm new to vb.net and it seems I wouldn't be able to solve this
without help.
I have a pipe delimited file that has to be saved in txt format
so it could be accepted by my DTS package.
If I open and save the file manualy in Wordpad - it works.
(not in Notepad otherwise formatting is changed and DTS package
won't accept it.)

File.Copy(strPath,strTxtPath) method of System.IO - creates the copy
of the file with .txt extension as needed,but format is like in
notepad - all screwed.
I need the file to be opened and saved in Wordpad format
programmaticaly.

I'd really appreciate if anyone who knows how to do it let me know.

Thank you very much.
Jul 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Jeff Levinson [mcsd]" <je***********@comcast.net> wrote in message news:<01****************************@phx.gbl>...
I'm not sure exactly what the problem you're having, but
you can solve it by putting your text in a RichTextBox
control. Then call the Save method of the control. This
will save a file in rtf format which I believe is the
internal format used by wordpad (99% certain) but in any
case it will preserver any formatting. You can also copy
and paste Word docs into the richtextbox so you don't
have to code any of word's functionality.

Hope that helps.

Jeff Levinson

Author of "Building Client/Server Applications with
VB.NET: An Example Driven Approach"

Thank you, Jeff, for your reply.
I've tried RichTextBOx control too - it didn't work.
My original file has extension .px.
I've created the file with the same name .txt first and
then I've used SaveFile method of RichTextBox control.
Somehow it cleared the data in the file.

I will try to reference excel object and open the file with xls
extension and then save it as text then.

It's like a nightmare.
For some reason DTS cannot find delimiter if the file isn't saved in wordpad
or with other text format but not notepad.

Thank you again,
Maya
Jul 19 '05 #2

P: n/a
"Jeff Levinson [mcsd]" <je***********@comcast.net> wrote in message news:<01****************************@phx.gbl>...
I'm not sure exactly what the problem you're having, but
you can solve it by putting your text in a RichTextBox
control. Then call the Save method of the control. This
will save a file in rtf format which I believe is the
internal format used by wordpad (99% certain) but in any
case it will preserver any formatting. You can also copy
and paste Word docs into the richtextbox so you don't
have to code any of word's functionality.

Hope that helps.

Jeff Levinson

Author of "Building Client/Server Applications with
VB.NET: An Example Driven Approach"
-----Original Message-----
Hey, there!

I'm new to vb.net and it seems I wouldn't be able to

solve this
without help.
I have a pipe delimited file that has to be saved in txt

format
so it could be accepted by my DTS package.
If I open and save the file manualy in Wordpad - it

works.
(not in Notepad otherwise formatting is changed and DTS

package
won't accept it.)

File.Copy(strPath,strTxtPath) method of System.IO -

creates the copy
of the file with .txt extension as needed,but format is

like in
notepad - all screwed.
I need the file to be opened and saved in Wordpad format
programmaticaly.

I'd really appreciate if anyone who knows how to do it

let me know.

Thank you very much.
.


Strange,
I replied back to this message in the morning and it's not here.

Anyway,
I've tried RichTextBox.SaveFile method too.
It clears up the file instead of saving in the format I need.

I found the solution by using Excel object.
I open the file with excel and save it as txt afterwards.
It saves it as with Wordpad.

Thank you very much for your reply.
Jul 19 '05 #3

P: n/a
You should look into saving the file with the proper encoding.
I suspect that your file I/O is saving the file in the default system
encoding(probably Unicode)
and what you need is ASCII or something similar.

You need to explicitly write the file with a specific encoding(from
System.Text.Encoding).
You need to write it using a StreamWriter object.
here's the code to get you started:

Dim fs As FileStream = File.Create("MyFileName")

'I specify the encoding with which the file will be written in the second
constructor parameter

Dim writer As StreamWriter = New StreamWriter(fs,
System.Text.Encoding.ASCII)

writer.Write(MyText)

writer.Close()

Should be short and simple after that.

--
Regards,

Roy Osherove
http://www.iserializable.com
---------------------------------------------

"Maya" <ma********@us.pwcglobal.com> wrote in message
news:71*************************@posting.google.co m...
Hey, there!

I'm new to vb.net and it seems I wouldn't be able to solve this
without help.
I have a pipe delimited file that has to be saved in txt format
so it could be accepted by my DTS package.
If I open and save the file manualy in Wordpad - it works.
(not in Notepad otherwise formatting is changed and DTS package
won't accept it.)

File.Copy(strPath,strTxtPath) method of System.IO - creates the copy
of the file with .txt extension as needed,but format is like in
notepad - all screwed.
I need the file to be opened and saved in Wordpad format
programmaticaly.

I'd really appreciate if anyone who knows how to do it let me know.

Thank you very much.

Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.