OpenFileDialog.FileName and FolderBrowserDialog.SelectedPath are not the same datatype ???

  • Thread starter Thread starter Koala Beer
  • Start date Start date
K

Koala Beer

Hi,

Here is something i can't figure out what i am doing wrong:

I use a OpenFileDialog to select a file. I put the result string from
the FileName property in a textbox on my form. Later on I save the
..Text property to an xml file. Nothing happens, the filename is not
writen to the xml file, and there is no exception.

When I replace the OpenFileDialog with a FolderBrowserDialog and I
copy the SelectedPath string to the textbox, and save it to the xml
file everything works fine.

Is there a difference between the both? They should both be a string.
When I debug the application I can see them both apear as string
literals.

I you can help me out on this one that would be great!

regards,

David
 
David,

I don't think that it has to do with the dialog that you use. You said
that you store the value in a textbox, and then to an XML file. If you see
the value in the textbox, then assuming the code to save to the XML is
right, everything should be fine.

Of course, it's hard to tell without seeing any of your code. Can you
give an example?
 
Nicholas,

You are right, it has got nothing to do with the dialogs.

I was writing a small test to prove my point, and when I run it for
the first time I also found out what I was doing wrong.

I didn't realise that when using the filedialog the default directory
is also changing, so when I write the xml, is ends up in the wrong
directory. When I read back the xml from the home directory of my
application it looks as if nothing has been written.

How stupid can one be!

Anyway, thanks for your reaction and for getting me to write the test
program.

regards,

David
 

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

Back
Top