Sale Posted August 14, 2003 Posted August 14, 2003 Hi all, I'm having a bit of a problem with OpenFileDialog and FileFilter. This is my code: private void btnBrowse_Click(object sender, EventArgs e) { OpenFileDialog ofdMsgPath = new OpenFileDialog(); ofdMsgPath.CheckFileExists = true; ofdMsgPath.InitialDirectory = "c:\\"; ofdMsgPath.Filter = "Text files (*.TXT)|*.TXT|HTML files (*.HTM, *.HTML)|*.HTM;*.HTML|All files (*.*)|*.*"; ofdMsgPath.FilterIndex = 1; ofdMsgPath.RestoreDirectory = true; ofdMsgPath.ShowReadOnly = true; ofdMsgPath.ReadOnlyChecked = true; if (ofdMsgPath.ShowDialog() == DialogResult.OK) { txtFile.Text = ofdMsgPath.FileName; } } Now, this works fine until I change the filter during runtime which causes the whole content of the current directory to disappear. Also html/htm file icon is replaced with the one for unrecognised file types!? Have no idea what is going wrong. Any help/guidence would be appriciated. Thanks Quote
*Experts* mutant Posted August 14, 2003 *Experts* Posted August 14, 2003 Are you changing the filter of the dialog in code or you mean when you open the dialog and select a file type from the dropdown list? Quote
Sale Posted August 14, 2003 Author Posted August 14, 2003 When I open the dialog and select a file type from the dropdown list. Sorry for the confusion. Quote
*Experts* mutant Posted August 14, 2003 *Experts* Posted August 14, 2003 If you change the filter then the dialog may seem empty as there is no files of the selected type there. If thats not the case I cant help you much here as that or the icon change didnt happen to me when I tested the code. Quote
Sale Posted August 14, 2003 Author Posted August 14, 2003 I don't think that's the problem as all directories disappear as well. The wierd thing is that I don't remember having this problem few days ago. It must be something I changed along the way. Thanks for you help. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.