saveFileDialog - bug & question

  • Thread starter Sergei Shelukhin
  • Start date
S

Sergei Shelukhin

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top