Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filter property of openfiledialog not working [closed]

i am close to finishing a brainfuck ide for my c# project in school. one of the problems nagging me is that the filter of the openfiledialog does not work when i try to open a .b code file. i save a file with the extension .b in notepad, then i try to open it with the ide. only problem ist, when i choose *.b-Files from the extension dropdown, i dont get any files displayed, just folders. when i choose to display any file, it works fine.

any ideas? here is my method for opening the file:

public void oeffnenDatei()
{
    OpenFileDialog ofd = new OpenFileDialog ();
    ofd.InitialDirectory = "C:\\";
    ofd.Multiselect = false;
    ofd.Filter = "Brainscramble-Dateien (*.b) | *.b | Alle Dateien (*.*)|*.*";
    if ( ofd.ShowDialog () == DialogResult.OK )
    {
        addTab ( ofd.SafeFileName );
        StreamReader reader = new StreamReader ( ofd.FileName );                
        setCode ( reader.ReadToEnd () );
    }           
}
like image 974
LeonidasFett Avatar asked Feb 18 '23 06:02

LeonidasFett


1 Answers

You have a space after the extension *.b in the filter property
This will work

ofd.Filter = "Brainscramble-Dateien (*.b)|*.b|Alle Dateien (*.*)|*.*";

Curiously, the space in front is not a problem

like image 153
Steve Avatar answered Feb 21 '23 02:02

Steve