saveFileDialog - bug & question

From: Sergei Shelukhin (raven_at_at_home.domonet.ru)
Date: 08/08/04


Date: Sun, 8 Aug 2004 18:21:19 +0400

Ok, I finally got to .NET development after a long break and i decided to
write an app :)

I started with functionality classes, so my app is currently console, and
what it did (at work) was do something, get big xml document assembled, and
then prompt the user for sme path to save it to and save it.

Here's the basic code (sorry, it's not indented correctly, I posted right
from VS and it doesn't seem to keep indent; well, it is small and simple
anyway):

public static int Main(string[] args)
{
  XmlDocument xmlDocument = new XmlDocument();
  FileSystemInfoLister xmlFS = new FileSystemInfoLister();
  xmlFS.Extension = "mp3";
  xmlDocument = xmlFS.GetFileSystemInfoList("e:\\");
  SaveFileDialog saveFileDialog = new SaveFileDialog();
  saveFileDialog.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*" ;
  saveFileDialog.FilterIndex = 1;
  saveFileDialog.RestoreDirectory = true;
  saveFileDialog.OverwritePrompt = false;
  saveFileDialog.DefaultExt = "xml";
  if ( saveFileDialog.ShowDialog() == DialogResult.OK )
  {
    xmlDocument.Save(saveFileDialog.FileName);
  }
  return 0;
}

The classes finsih functioning and the program hangs up. Console window is
up and nothing's happening. If oyu break it, turns out, it is hanging on
"if" line.
I tried moving showdialog to separate line before if - it is hanging on it.
If you step into, step over or continue, it continues hanging; break it and
it is on the same line. No dialog appears. What's happening?

Oh and btw, there's addtional problem with dialog.
When it worked (at work ;) ), the dialog behaved strangely without
  saveFileDialog.OverwritePrompt = false;
line. Namely, it returned "Cancel" result when I picked existing file and
confirmed that I want to overwrite it. Why's that?



Relevant Pages

  • Re: Can an application hang Windows 2000?
    ... be several things hanging the machine, and the application is only one ... version of the app with garbage ... it will not be pro-active enough at trimming memory. ... > earlier OS due to kernel mode must-succeed allocations. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Running a .NET 1.0 application on Windows.NET CE version 5.0 (CE5)
    ... when you debug the app - where is it hanging? ... Ginny Caughey ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Server 2003 + TS with RDP 5.2
    ... Is this a consistent occurence? ... are there any event logs when this occurs? ... current app loses focus yet no other app or background pop has it. ... I spoted the fact was not hanging and by clicking on the Grey task bar ...
    (microsoft.public.windows.terminal_services)
  • Display of Command execution.
    ... I have some queries with a command time out of some 10 minutes. ... taking solong that users offen think the app is hanging. ...
    (microsoft.public.dotnet.framework.adonet)
  • SaveFileDialog randomly adds file extension
    ... I have an app where we turn the AddExtension property of the SaveFileDialog ... to true because I always want the extension returned as part of the filename. ...
    (microsoft.public.dotnet.framework.windowsforms)