open custom extnsion files with cutom applications using c#.net

  • Thread starter Thread starter Kevin Spencer
  • Start date Start date
K

Kevin Spencer

You can add file extension associations easily in a Setup Project.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Magician

A man, a plan, a canal.
a palindrome that has gone to s**t.
 
If you are using .NET 2.0 then this can be done using registry
modifications.

I am just writing an article on this for my web site. Should be up in a few
days.

For the loading of the file you simply need to adjust your Main() method to
accept arguments and make sure that the filename is passed to the executable
as an argument. Check out
http://www.blackwasp.co.uk/WindowsFormsStartParams.aspx for how to do this
bit of the job.
 
Hi
I am developing a C#.Net windows application for my project.
In that project I have an IDE to work on. The application is similar to
Adobe Photoshop.

My requirement is as follows.
1) I must be able to save my work in a file with custom file extention
(similar to *.PSD in photoshop)
2) After I save my work, if I double click on that file, my work should be
opened with my application automatically and I need to be able to work on
that as usual.
(similar to *.psd file, if we open that file, the file will be opened in
photoshop automatically)

How to do this functionality programatically?
(when we double click the file, my application has to be opened and file
must be opened in that application.)
Please help me out from this situation and guide me in right direction ASAP.

Thanks in advance
 
Hi BlackWasp
Thanks for the solution....

I followed what ever you said. Finally I am able to open my application when
I double click the file which is having my custom extention.
The below link guided me very well up to now...
http://www.blackwasp.co.uk/ProgrammaticFileTypes.aspx

But here I have one problem,

My application is cbr.exe, and the file extention is *.cbw

I am able to generate myFile.cbw,
I am able to get my own icon for cbw file type.
I am able to run "cbr.exe when *.cbw files are double clicked in the
explorer.

But I could not be able to read the myFile.cbw file content when cbr.exe is
run.
I want to read the file contents of cbw files which I double click and open
with my application "cbr.exe"
When I click the file (which has custom extention, say *.xyz) I am able to
run my application. I could not be able to read the file with my application
at the time of opening it with my application.

Please help me out from this situation

thanks
 
Hi again,

The main thing to check for is that you are setting the command that you
execute to cbr.exe %1.

The %1 is important as this will be replaced with the name of the file. So,
say you double-click "c:\cheese.cbw", the command that is executed will be
cbr.exe c:\cheese.cbw.

Effectively this is the same as clicking Start then Run and typeing cbr.exe
c:\cheese.cbw before clicking the OK button. (If you do this, does it load
your app with the document?)

Secondly, you need to be able to capture that this has been passed to your
application. I explain this in
http://www.blackwasp.co.uk/WindowsFormsStartParams.aspx.

Change the Main() definition to Main(string[] args). On starting, check if
args==null. If args is null then no document was passed to the executable.
If it is not null then args[0] should contain the name of your file. You
can then load this using whatever functions you need.

Let me know how you get on either through the newsgroup or drop me a line
via my contact page.
 
Back
Top