Reputation: 453
I have to create a file whose extension is different than usual file extension i.e., other than text or xml or any image files etc. say, .ikl
I am able to create such file but it is opening and contents are being exposed using notepad or notepad++.
I want that this file cannot be opened via any of such programs like notepad and even if it is it should not show actual information.
Like if we open pdf file in note pad it does not shows actual contents but lets say Garbage values..
However i want to parse this file for some values too and this parsing can be done by a program or tool created by me only.
How can I do this?
Upvotes: 1
Views: 562
Reputation: 70671
The data in a PDF isn't garbage. It's just not plain text. Anyone with the PDF specification in their hands can write code to interpret the data.
Likewise your own data. You can make it harder to read, but you can't make it impossible, not if you want your user to be able to read it again. The closest you can come is to encrypt the data using some user-provided information. E.g. the user provides the public key of some public-key encryption scheme. Then without the private key, the data is unreadable.
If you're just trying to discourage prying eyes but don't need absolute security, you can convert the data to some binary format. For example, you can kill two birds with one stone by using GzipStream
to compress the data, making the file smaller and harder to read. :)
Upvotes: 3
Reputation: 17605
To my understanding, it is impossible to have full control over the application actually used for opening or viewing a custom file type. However, you could use a windows shell extension to open the file with a custom viewer, as discussed here or here. Basically, the shell extension is a registry entry directing the file to the desired application for handling it.
Upvotes: 2
Reputation: 14334
Any file can be opened in Notepad++ if you try hard enough. That is just how windows works.
The trick is to make sure that you have associated your file extension with the intended application so that the user is less inclined to mess around. This is typically acheived with a windows installation package for the 'viewer' application.
Upvotes: 2