create unique file extension - VB.net 2003+

Hi Experts,

I have created a simple winform with an RTF box& simple text editor app& I would like to know if it is possible to save my files/and open files with a unique file extension&

So instead of saving as txt or rtf&. I would like to create my own [file extension] so that my application can open it?

Any generous code would be appreciated as I'm not that experienced on vb ;)

Cheers,
Roberto
RobertoFreemanoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AruspexCommented:
Hey RobertotoFreemano,

You can use whatever extension you would like. There is no restriction.

As an example, check this out;

NB: put the following at the top of the file.
Imports System.IO



  Dim filePath As String = "C:\Test.UniqueExtension"
 
        'Write the file
        Dim sWriter As StreamWriter = Nothing
        Try
 
            sWriter = New StreamWriter(filePath)
            sWriter.Write("This is a test!")
        Finally
 
            If Not sWriter Is Nothing Then
                sWriter.Close()
            End If
        End Try
 
        'Read the file
        Dim text As String
        Dim sReader As StreamReader = Nothing
        Try
            sReader = New StreamReader(filePath)
            text = sReader.ReadToEnd()
        Finally
 
            If Not sReader Is Nothing Then
                sReader.Close()
            End If
        End Try

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
oobaylyCommented:
You will also have to tell windows to associate the extension with your application. Also, you then have to accept arguments passed to the application by windows, ie. the path to the file that was double clicked in Windows Explorer.
0
RobertoFreemanoAuthor Commented:
Thanks Guys,

I will test this tonight & let you know how I get on.

Roberto
0
RobertoFreemanoAuthor Commented:
Thanks Guys.... That worked great!

Cheers,
Roberto
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.