By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,573 Members | 1,797 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,573 IT Pros & Developers. It's quick & easy.

OpenFileDialog messing up XmlSerializer

P: n/a
The code is here:

http://www.osbornewood.com/matthew/vb.cfm

I am trying to Serialize soundFile.Text to an XML file. I have two buttons:
Browse and Save Settings. You can enter a value the textbox and click Save
Settings and it will generate a file settings.xml. The contents of
soundFile.Text are in that file.

You can change the value of soundFile.Text and click Save Settings and it
will regenerate the XML file.

Here is the strange part. Click Browse, choose any file, and click OK.

Change the value of soundFile.Text and click Save Settings. It will not
regenerate the XML file!

Does anybody have any clue what's going on?

Matthew
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I figured it out.
I was using a relative path to the XML file.
Example:
Dim fs As FileStream = New FileStream("settings.xml", FileMode.Create)

When I choose a file with the OpenFileDialog, it changed the current path to
the directory where the other file is stored.
It was generating the XML file after all, but saving it to my sound files
directory instead of my program directory.

I created a global variable with the full path:
Dim myXmlFile As String = Path.GetFullPath("settings.xml")

And I used that variable in my code:
Dim fs As FileStream = New FileStream(myXmlFile, FileMode.Create)

No more problems.

Matthew
Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.