Click here to Skip to main content
14,454,989 members
Rate this:
Please Sign up or sign in to vote.
See more:
how do I create a new extension? type .txt .doc for example, I'm programming in C # in Visual studio, the idea is to make a program that has its own extension and uses it to be able to save.

What I have tried:

I tried to find something on youtube, but nothing that would give me what I want
Posted
Updated 14-Feb-20 8:02am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You can make up any extension you want.

Writing to a file can be very easy, for example:
string text = "Some data to write to file";        System.IO.File.WriteAllText(@"C:\Test\WriteText.myExtension", text);


If you want your application to launch when someone double-clicks it, that's another issue and you just need to register your app as the program to handle that extension.
   
Comments
João Henrique Braga 14-Feb-20 13:33pm
   
thank you very much, but about my application to launch when someone double-clicks it, how i register my app as the program to handle that extension?


and by doing this will I be able to save all the data contained in my program?
ZurdoDev 14-Feb-20 13:45pm
   
1. To associate a file extension with your application will be different for windows or linux or apple. See https://stackoverflow.com/questions/2681878/associate-file-extension-with-application for one example.
2. But that's only half the story. Then you need to look at how to parse startup parameters so that in your code you know when a file is being passed in.
3. You can save data any way that you want. Text files, database, etc. That's your choice.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100