open With Dialog

  • Thread starter Thread starter daveL
  • Start date Start date
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
 
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;
}
 
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
 
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
 
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.
 
Back
Top