473,399 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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

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
3 11225
"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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: sea | last post by:
I have text files in the following format: 123,34, ,345,890, 123,23 .. .. .. As you can see, the problem is that (1) the commas can occur in
4
by: Maya | last post by:
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...
7
by: Lumpierbritches | last post by:
Thank you in advance for any and all assistance. It is greatly appreciated. I would like a command button in VB.Net 2002 to open a text file, then to allow text from a textbox on the current form...
21
by: iwdu15 | last post by:
how can i create a code to make my program create an rtf file? heres what i have so far, any help would be appreciated: Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As...
3
by: Jeff | last post by:
This is not as simple as I thought. Using Print # I am outputting content for a text file. I wanted at certain points to force a page break so I thought a Chr(12) for a form feed may work. If...
2
by: GW | last post by:
After the conversion and fixing some errs VS2005 threw, project ran OK. Opened xxx.vbproj file after the conversion to VS2005 from VS2003. Changed (usng wordpad) ../msbuild/2003 to 2005...
13
by: George | last post by:
Hi, I am re-writing part of my application using C#. This application starts another process which execute a "legacy" program. This legacy program writes to a log file and before it ends, it...
6
by: =?Utf-8?B?TUNI?= | last post by:
I try to open a log file that is logging infomation by another process: StreamReader sr = File.OpenText(filePath); I got the exception message: The process cannot access the file...
1
by: vinoth124 | last post by:
Hi Friend, I need to open a "D:sam\a.wif" file in the wordpad then I need to save the same file immediately with out any updation and then I need to close it. For opening a file I used this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.