tags:

views:

209

answers:

2

I am trying to find file associations before attempting to launch the file, the best way I could come up to find that association was using the assoc command, my question is can I run this command through some API way? Right now the application launches a cmd window to run the command and then parse the output.

+2  A: 
try
{
    Process.Start(@"C:\textfile.txt");
}
catch(Win32Exception e)
{
    Process.Start(@"C:\");
}

Works for me. Starts the associated application (notepad) with the file. I realize it's not the best way with the exception handling, but it does work.

Moose
Yep, that's what I was getting at. :thumbup:
JMD
+2  A: 

Check out http://www.codeproject.com/KB/dotnet/System_File_Association.aspx

m-sharp
this should,but the documentation says minimum operating system is windows vista, and i am targetting xp and up....
Where does it say it requires Vista? All I read in there was that it requires administrative access, "especially under Vista".
JMD
at the end it saysInterface Information Minimum operating systems Windows Vista