473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

File Association launch default windows dialogue

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 !

Jerry
Nov 15 '05 #1
1 4447

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)
{
try
{
ProcessStartInfo psi=new ProcessStartInfo(@"C:\Documents and
Settings\v-jetan\Desktop\adf.asdf");
Process.Start(psi);
}
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";
Process.Start(psi);
}
}
}
In the solution, I create a random file adf.asdf which has no file
association.

================================================== ===============
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! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kathy Benson | last post by:
Hi, I need to open an external file, such as *.htm from a Java program. I need to open this file by the default program that handles this extension on the machine. So *.htm should always be opened...
8
by: L Mehl | last post by:
Hello -- Fairly often, but not always, when I start the app by clicking the mdb or an icon set up to start it, I get the message "Cannot find the file 'c:\path...\dbname.mdb' ...." and...
2
by: Peter | last post by:
I have created a Setup project wich includes couple of text file and it also includes file association of .tsrx. After the application is installed if I happen to delete any one of the text...
1
by: Allen | last post by:
I have installed the Updater Application Block, and then I should Deploy the QuickStarts. " Install the QuickStarts After you install the Updater Application Block, you should install the...
5
by: Mr Gordonz | last post by:
Hi all, I want to put a button on a page, and when the user clicks it, the standard Windows "Open File" dialogue box opens, and the user can browse/select a file on their PC. Having selected a...
6
by: Nak | last post by:
Hi there, I am implementing file association from within my application, association that occurs after installation. Anyway, I remember a while back seeing a key in the registry that was used...
28
by: Tim Daneliuk | last post by:
I have a program wherein I want one behavior when a file is set as executable and a different behavior if it is not. Is there a simple way to determine whether a given named file is executable...
0
by: pek | last post by:
First Question: OK, I know how to make a simple file association with the registry. What I can't figure out is how do I fetch multiple files. So far I managed to add to the context menu an "Add to...
3
by: LordHog | last post by:
Hello, How would I go about finding the default handler, let's say a text file (*.txt), then launch the default handler with the file as an argument? I had found how to launch an external...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.