jin katama

hello friends may i known how to create my own extension using vb.net and add text to it

when i open the file it should display symbol when the file is opened to read using notepad

like that when u use notepad to read a texfile

for example if i have a bank account management project to record the transaction i use the file name as *.dat

like that how create the file extension "filename.efd"

i tell u in simple

i want to know how to create file extension in vb.net. For example, if have window application that

has file extension like (.kay). If i save a file and i want the file to open my application. any hints

Re: Visual Basic Express Edition create my extension



I always see you ask and ask

are you ever gonne show some code

or are you just letting us do the work

for you every time


Re: Visual Basic Express Edition create my extension

jin katama

this my program

when i click the buttton

the 2.mye(myextension) file is created (open with)when i open it in notepad it displays value i should do like that

when a use open's it should open my project and display the content of 2.mye

Code Block

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

If EFiles("C:\1.txt") = True Then

MsgBox("Encrypted File")

End If

End Sub

Private Function EFiles(ByVal filePathOne As String) As Boolean

Dim fileOneStream As New FileStream(filePathOne, FileMode.Open)

Dim sha1 As New SHA1Managed

Dim fileOneHash As Byte() = sha1.ComputeHash(fileOneStream)


For index As Int16 = 0 To fileOneHash.Length - 1

File.WriteAllText("c:\2.mye", index)


End Function

Re: Visual Basic Express Edition create my extension



But i don't understand what you want to

acomplish here.

Can you explain in more detail what you

kind of problem you have.

if i run you code the only thing i have is

that it cannot find the file


Re: Visual Basic Express Edition create my extension

Martin Xie - MSFT

Hi Jin,

You are talking about how to create a file extension and associate the extension with your application.

1. How To Associate a File Extension with Your Application


Call the RegCreateKey& and RegSetValue& application programming interface (API) functions.

2. File Association in VB.NET (using the third-part component: Registry Actions.dll.)


Good sample including demo, source code, detailed steps and instruction.

E.g. creating file extension .Hello

My.Computer.Registry.ClassesRoot.CreateSubKey(".Hello").SetValue("", "Hello", Microsoft.Win32.RegistryValueKind.String)

My.Computer.Registry.ClassesRoot.CreateSubKey("Hello\shell\open\command").SetValue("", Application.ExecutablePath & " ""%l"" ", Microsoft.Win32.RegistryValueKind.String)

You can also create file extension(such as .efd, .kay, .mye) in Windows Explorer.

Tools menu -> Folder Options -> File Types

You can create New Extension by specifying File Extension and Associated File Type.

Please check these threads having the similar issue:

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=2150566&SiteID=1

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=2253699&SiteID=1



Re: Visual Basic Express Edition create my extension

jin katama

thank u a lot

i am having an another doubt how i get the data of the "filename.hello" whether i have use api or not and pls tell me

what is api and how it works and how to get done

Re: Visual Basic Express Edition create my extension

Martin Xie - MSFT

how i get the data of the "filename.hello"

-> It depends on the file format of .hello files.

Usually we read text format files using StreamReader class.

Code Block

Imports System.IO

Dim txtReader As System.IO.StreamReader

txtReader = New System.IO.StreamReader("D:\data.xml")

RichTextBox1.Text = txtReader.ReadToEnd


We read binary format files using BinaryReader class. BinaryReader almost can read any file, including text format files.

Just a sample.

Imports System.IO

Dim fs As FileStream = New FileStream("D:\data.dat", FileMode.Open)

Dim binReader As BinaryReader = New BinaryReader(fs, System.Text.Encoding.Default)

'set the file pointer to the beginning

binReader.BaseStream.Seek(0, SeekOrigin.Begin)

While (binReader.PeekChar > -1)

Dim chr As Char = binReader.ReadChar

RichTextBox1.Text += chr.ToString

End While

' RichTextBox1.Text = binReader.ReadChars