open With Dialog

D

daveL

hi
does anybody have a link or know how to
get the windows open file with dialog

i have a datagrid with many different file types
i want to let the user open when they right click on a cell with a FileName
if i get a no file association Error , i want to use the open with dialog

any help much appriciated
DaveL
 
M

Morten Wennevik [C# MVP]

Hi Dave,

The open file dialog is called just that, and you use it as any other dialog

OpenFileDialog ofd = new OpenFileDialog()
if(ofd.ShowDialog() == DialogResult.OK)
{
string filename = ofd.FileName;
}
 
I

Ignacio Machin ( .NET/ C# MVP )

hi
does anybody have a link or know how to
get the windows open file with dialog

i have a datagrid with many different file types
i want to let the user open when they right click on a cell with a FileName
if i get a no file association Error , i want to use the open with dialog

any help much appriciated
DaveL

Hi,

Is this a windows or a web app?
if a web app it's very simple, you get it by default
If a win app take a look at this link http://www.codeproject.com/KB/shell/openwith.aspx
 
I

Ignacio Machin ( .NET/ C# MVP )

Hi Dave,

The open file dialog is called just that, and you use it as any other dialog

OpenFileDialog ofd = new OpenFileDialog()
if(ofd.ShowDialog() == DialogResult.OK)
{
    string filename = ofd.FileName;

}

I do not think this is the question, I think that the OP has a grid
where a column represent files, if the user double click it he wants
that file open. His problem is that the grid might content files with
unregistered extensions and in this case he want to use the "open
with" dialog that windows present from the explorer
 
P

Pavel Minaev

hi
does anybody have a link or know how to
get the windows open file with dialog

i have a datagrid with many different file types
i want to let the user open when they right click on a cell with a FileName
if i get a no file association Error , i want to use the open with dialog

You should just use Process.Start(), giving it the name of the file
you want to open. If it's a registered document type, it will be
opened using the default associated application. If it's not
registered, then the usual Windows "Open With" dialog (the one that
suggests to pick the application from the list, or look for supported
viewers on the Web) pops up.

The only caveat there is that if it's an executable, it will run.
Which is technically correct, since that's what "opening" an
executable in the Shell means, but it is not always appropriate.
 

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