locked
Problem with Microsoft.Win32.OpenFileDialog/SaveFileDialog RRS feed

  • Question

  • Hello,

    I seem to be having a rather strange bug in windows 10 using WPF I know WPF has not been updated to support windows 10 effects but it should still work correctly yes?

    My problem, as the title says is with the Win32 Dialogs now I can get both to open however for some strange reason they are not showing files that match their only / selected filter!

    So as you can see I have a save dialog but it's not showing test.wkproj but if I try to save it knows it's there and prompts for an overwrite. the Exact same thing happens with the OpenFile version it will not show the file but if I type in the filename test.wkproj it will load the file so is this a bug in Windows 10 or WPF? 

    OS Info: Windows 10 Home none-preview build channel
    VS Info: 2015 Community Edition

    Code Used:

    Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
    
    // Set filter for file extension and default file extension 
    dlg.DefaultExt = ".wkproj";
    dlg.Filter = "WebKidz Project|*.wkp,*.wkproj";
    
    // Display OpenFileDialog by calling ShowDialog method 
    Nullable<bool> result = dlg.ShowDialog();
    
    // Get the selected file name and display in a TextBox 
    if (result == true)
    {
        // Open document 
        currentProjPath = dlg.FileName;
        currentProject = new Classes.ProjectManager(dlg.SafeFileName.Replace(".wkp", ""));
        currentProject.BuildTreeView(ProjectList);
        currentProject.Save(currentProjPath);
        OverlayVisability(Visibility.Hidden);
    }

    Tuesday, April 19, 2016 12:56 AM

Answers

  • If you want to be able to accept and filter several different extensions under the single name of "WebKidz Project", you should replace the ',' (colon) with a (semi-colon) ';':

    dlg.Filter = "WebKidz Project|*.wkp;*.wpproj";

    Hope that helps.

    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

    • Marked as answer by Martin Barker Wednesday, April 20, 2016 1:17 PM
    Tuesday, April 19, 2016 6:25 PM

All replies

  • Change your filter to:

     dlg.Filter = "WebKidz|*.wkp|WebKidz Project|*.wkproj";


    Hope that helps.

    Technet articles: WPF: Layout Lab; All my Technet Articles

    Tuesday, April 19, 2016 3:58 PM
  • If you want to be able to accept and filter several different extensions under the single name of "WebKidz Project", you should replace the ',' (colon) with a (semi-colon) ';':

    dlg.Filter = "WebKidz Project|*.wkp;*.wpproj";

    Hope that helps.

    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.

    • Marked as answer by Martin Barker Wednesday, April 20, 2016 1:17 PM
    Tuesday, April 19, 2016 6:25 PM