How to create a custom file extension in C #?

I need help creating a custom file extension in my C # application. I created a basic note management application. Now I save my notes as .rtf (note1.rtf). I want to be able to create a file extension that only my application understands (e.g. note.not, maybe)

+6
source share
5 answers

File extensions are an arbitrary choice for your formats, and it really depends on your application registering a specific file extension as a file of a certain type in Windows after installation.

Running your own file format usually means that you save this format using a format that only your application can handle. It can be in either text or binary format, and it can even use XML or any other format, as your application should easily parse it.

+8
source

As a deployment point, it should be noted that ClickOnce supports file extensions (unless it is in "online only" mode). This makes it easy to configure the system to recognize new file extensions.

You can find this in the project properties -> Publish -> Options -> File Associations in VS2008. If you do not have VS2008, you can also do it manually , but it is not fun.

+10

:

?

RTF. , , , RTF, , , RTF .

, . , RTF, Rich Edit ( , ) , .

, ...

RTF .rtf. , Windows .

Windows , , , .

. ( HKLM\Software\Classes) ( HKCU\Software\Classes), . MSDN, SO Vista.

+4

, ,

+2

, .

I feel your problem is: "How can I save a file in something other than RTF?" You will have to come up with your own format, but you don’t really want to. You can still save RTF to a file named mynote.not.

I would advise you to use a format that can be read from other programs. Your users will be grateful if they want to do something with their notes that are not supported by your program.

+1
source

All Articles