Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8903275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:49:45+00:00 2026-06-15T01:49:45+00:00

I need to show a folder dialog box so the user can select a

  • 0

I need to show a folder dialog box so the user can select a path before my application runs. I have everything working fine but I can’t seem to be able to keep the error MessageBox on the foreground. If the user selects the wrong path a message box will pop up but it will stay in the background behind any open window on the desktop.

I’m new to WPF, with the winforms version of this application I could specify fdb.ShowDialog(this) and it would keep the error messagebox on the foreground. But with WPF the message box window always stays behind all other open windows.

Any ideas on how I could solve this? Thanks.

    while (!found)
    {
        if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
        {
            if ((File.Exists(Path.Combine(fbd.SelectedPath, "user.exe"))))
                return fbd.SelectedPath;
            else                   
                System.Windows.Forms.MessageBox.Show("Cannot find user.exe in the selected path! Please try again.", "File Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);

        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:49:46+00:00Added an answer on June 15, 2026 at 1:49 am

    Move your code to Window_Loaded event instead of calling it from constructor –

    <Window Loaded="Window_Loaded"/>
    

    Code behind –

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        // Your code here
    }
    

    Since, your window is not loaded yet as the code execution haven’t get passed the constructor yet and in the meanwhile error message pops up. So, once the window gets loaded it will comes over the message box.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Show in folder button which executes the following: explorer.exe /select,C:\dir\somefile.txt In
I have a problem with my android application. I need to show all files
Hello I have this code to show image from folder in php : $handle
I have a folder structure in my server and I need to navigate through
i have this page (very simple to show what i need) to upload flv
I need to show a graph(piegraph and XYgraph) in HTML file. I have used
I have a POSH script that sets a user's access to a specific folder
I need show a notication modal window.. But since its a fluid layout the
me again... I need show 10 or 20 or 50 results number of results
I need to show a form exactly in front of another form, this lead

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.