Developer, Former MVP, now at Microsoft - Best of 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
var ofd = new OpenFileDialog();ofd.EnableMultipleSelection = false;ofd.Filter = "Txt Files|*.txt|Silverlight Video Files|*.wmv";ofd.FilterIndex = 2;if (ofd.ShowDialog() != DialogResult.OK) return;FileDialogFileInfo fdi = ofd.SelectedFile;lbl.Text = fdi.Name; // lbl is a TextBlockif (ofd.FilterIndex == 1) //not robust but hey..{ StreamReader sr = fdi.OpenText(); txt.Text = sr.ReadToEnd(); // txt is a TextBox sr.Close();}else if (ofd.FilterIndex == 2) //not robust but hey..{ wmv.SetSource(fdi.OpenRead()); // wmv is a MediaElement}