Remember App. chosen in 'Open With...' dialog

J

Jeroen

The group and search engines revealed many hints on how to use the
'Open With...' dialog, for example at:

http://www.codeproject.com/csharp/openwith.asp

Now in addition to a solution as presented in the tutorial above, I
would like to remember the application that was chosen, so that I
don't have to ask the user next time.

The situation I'm trying to tackle is as follows. Our application
generates an html. I would like to offer them the 'Open With...'
dialog (they're familiar with) to let them choose the program they
want to use from then on to open html files generated in our
application.

Most commonly, we will have users that want to open html files
generated in _our_ application in MS Excel instead of their browser,
without changing the system wide setting for html files.

Any tips would be appreciated.
 
G

Guest

If I understand you correctly: you want to have files with a given extension
open in different applications when they're clicked in Windows Explorer?

The only way to do that is to write an application that is associated with
an extension and open another application based on some non-extension
criteria.

That's what Visual Studio does with *.*proj files. A third application you
don't ever see checks the contents of the file then runs either Visual Studio
2003 or Visual Studio 2005...
 
J

Jeroen

If I understand you correctly: you want to have files with a given extension
open in different applications when they're clicked in Windows Explorer?

Sorry, I probably explained the problem inadequately. In pseudocode,
the following is what I'm looking for:

/******************************/
class Example
{
private static object SomeApplication = null;
private static string FilePath = "C:\SomeJustCreatedFile.html";

private void OpenMyFile ()
{
if (SomeApplication == null)
SomeApplication = this.SelectAnApplicationThroughOPENWITH ();

System.Diagnostics.Process process = new
System.Diagnostics.Process();
process.Application = SomeApplication;
process.File = FilePath;
process.Start();
}

private object this.SelectAnApplicationThroughOPENWITH()
{
// Do something
}
}
/*****************************************************/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top