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 6951079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:10:26+00:00 2026-05-27T14:10:26+00:00

I’m working with winforms on Windows 7, using C# in Visual Studio 2010. Currently

  • 0

I’m working with winforms on Windows 7, using C# in Visual Studio 2010.
Currently in Windows 7 both install and from debugger the code below works. However, when the program is installed in Windows XP, the final line is never reached.

This code is called from a MenuStrip, and then passed to a subsequent method to perform the actions based on the item clicked in the menu. However, this is not the only place where SaveFileDialog is failing and it always fails on the ShowDialog() method.

Code for the MenuItem:

            private void saveOnlyPlaylistToolStripMenuItem_Click(object sender, EventArgs e)
            {
                try
                {
                    MainMenuClick(sender, e);
                }
                catch (Exception ex)
                {
                    StackTrace st = new StackTrace();
                    string methodName = st.GetFrame(1).GetMethod().Name;
                    Logger.LogToFile("Failure in " + methodName + ": " + ex.Message);
                }
            }

Code that is failing:

            Logger.LogToFile("Entered Save Only Playlist.");
            SaveFileDialog sfd = new SaveFileDialog();
            string playlistSaveLocation = config["PlaylistLocation"];
            if (!Directory.Exists(playlistSaveLocation))
                Directory.CreateDirectory(playlistSaveLocation);
            sfd.InitialDirectory = playlistSaveLocation;
            sfd.Filter = "L Playlist (*.lpl)|*.lpl";

            DialogResult result = sfd.ShowDialog();
            Logger.LogToFile("Result of Dialog: " + result.ToString());

I can’t figure out why the last line is not being called, it feels like the ShowDialog() method of the SaveFileDialog is no completing. Afterwards the program continues to run fine, but will no longer interact with the file directory and cannot make new processes.

There is no error left in the debugger, nor the event log. I’ve rebuilt it on a windows XP using Visual Studio 2010 and it worked fine, the error only seems to appear when the program is created in Windows 7 and then installed on Windows XP. Windows 7 is 64 bit.

I should note that I have all exceptions being thrown from Debug -> Exceptions.

I’ve searched around and there doesn’t seem to be many cases of a base method like SaveFileDialog failing, any ideas on what could be causing this issue?


Further analysis based on the answer below has lead to me to believe that perhaps this has something to do with how the SaveFileDialog is being called. Since this is being called from a MenuStrip, I believe it is coming out as a separate thread. This may be the reason why the ShowDialog() method is never returning, but I can’t pinpoint why that would be. In an effort to find the problem, I created a separate window form that did nothing but had a button to open a save file dialog. This button works, and correctly returns, but upon returning control back to the original thread it seems to fail again. This is all based on the logging I am placing for debugging purposes.

Logging code:

            public static void LogToFile(string message, FileInfo fInfo)
            {
                try
                {
                    if (!fInfo.Exists)
                        using (FileStream fs = fInfo.Create()) ;

                    message = DateTime.Now.ToString("yyyy-MM-dd hh-mm-ss") + ": " + message;

                    File.AppendAllText(fInfo.FullName, message + "\n");
                }
                catch (Exception ex)
                {
                    StackTrace st = new StackTrace();
                    string methodName = st.GetFrame(1).GetMethod().Name;
                    MessageBox.Show("Failure in " + methodName + ": " + ex.Message);
                }
            }

Code for additional Window:

            public partial class Buffer : Form
            {
                public Buffer()
                {
                    InitializeComponent();
                }

                private void Buffer_Load(object sender, EventArgs e)
                {
                    Logger.LogToFile("Entered Save Only Playlist.");
                    SaveFileDialog sfd = new SaveFileDialog();
                    sfd.Filter = "Playlist (*.lpl)|*.lpl";
                    DialogResult result = System.Windows.Forms.DialogResult.Cancel;
                    try
                    {
                        result = sfd.ShowDialog();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Dialog problem: " + ex.Message);
                    }
                    Logger.LogToFile("Result of Dialog: " + result.ToString());
                    MessageBox.Show("Result of Dialog: " + result.ToString());
                    DialogResult = result;
                }
            }

The code above works, and the MessageBox.Show() actually shows the dialog result.

  • 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-05-27T14:10:26+00:00Added an answer on May 27, 2026 at 2:10 pm

    Turns out this issue was simpler than I first realized. In windows XP a Save File or Open File Dialog will change the working directory and cause the program to look in that location. Unfortunately I had not anticipated this in my Logger and therefore the log file was moving to an unexpected location.

                Logger.WriteToFile("DEBUG TEXT", "Debug.log");
    

    Upon realizing this, the error quickly lead away from the SaveFileDialog and instead was resolved by ensuring all my files were being correctly referenced.

                string path = Path.Combine(Application.StartupPath, "Debug.log");
                Logger.WriteToFile("DEBUG TEXT", path);
    

    A simple problem, though in Windows 7 a SaveFileDialog does not permanently alter the working directory and this caused my confusion. Hope this helps anyone else who runs into this issue.

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

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.