By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,601 Members | 907 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,601 IT Pros & Developers. It's quick & easy.

File Association launch default windows dialogue

P: n/a
Hi Experts,

from my program I offer the user to launch different files from a directory
(normaly in this directory are .txt files) - but sometimes other files may
be in there - so if my program receives the "no program associated" I would
like to launch the standard Windows dialogue that pops up when double
clicking a file in windows explorer that has no association.

Thanks for any hints !

Nov 15 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a

Hi JerryP,

Thank you for using MSDN Newsgroup! My name is Jeffrey, and I will be
assisting you on this issue.

Based on my understanding, your application use Process class to invoke
many files in the system, but some of the files has no file association
with them, so a "No application is associated with the specified file for
this operation" exception will generate, you want to catch this exception
and open a "Open With" dialog for your file.

================================================== ===========
Actually, in Windows, the program open with is associated a "type" of file
with the same file extension instead of with a single file. So I think you
should parse the file extension of your unknown file and invoke this "type"
file's "Open With" dialog.

To invoke "Open With" dialog, you should use rundll32.exe to invoke the
shell32.dll with OpenAs_RunDLL parameter.

You can try the following Solution to see if it helps resolve your issue:
private void button1_Click(object sender, System.EventArgs e)
ProcessStartInfo psi=new ProcessStartInfo(@"C:\Documents and
catch(Exception ex)
if(ex.Message=="No application is associated with the specified file for
this operation")
ProcessStartInfo psi=new
ProcessStartInfo(@"C:\WINDOWS\system32\rundll32.ex e");
psi.Arguments=@" C:\WINDOWS\system32\shell32.dll, OpenAs_RunDLL .asdf";
In the solution, I create a random file adf.asdf which has no file

================================================== ===============
Please apply my suggestion above and let me know if it helps to you.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.