|
-
May 27th, 2004, 09:05 PM
#1
Thread Starter
New Member
OpenFileDialog & DataSets
I have a problem with using the OpenFileDialog object and datasets. Whenever I use the OpenFileDialog when the application is in run mode, it will change the current working directory of all datasets in use. So if I use a relative path when reading an XML file into the dataset, that path will change to the last folder browsed using the OpenFileDialog. This will cause an error when I go to use dataset.WriteXml() because the path has changed. Can someone please tell me a work around for this problem?
-
May 28th, 2004, 12:46 AM
#2
First off, I find it very strange that the CommonDialog would have an effect on a dataset. Can you post some code so that I can try it out here?
Second, the .WriteXML() method can take a filename argument which can contain the path, so that you can specify where to write it.
-
May 28th, 2004, 01:31 AM
#3
Hi.
This is probably because the dialog changes the current directory in windows, thus all relative paths are changed.
There's a property on the dialog called "RestoreDirectory".
If I understand correctly, setting this property to TRUE would cause the dialog to change the directory back when closing.
I hope this is what you need.
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
May 29th, 2004, 02:01 AM
#4
Thread Starter
New Member
Hi, thanks for the help but it is still causing the same error even when using RestoreDirectory = True
-
May 29th, 2004, 02:36 AM
#5
Hmmm, strange...
Well instead of using relative paths maybe you should use absolute.
Like this
VB Code:
MyAbsolutePath=IO.Path.Combine(Application.StartupPath,MyRelativePath)
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
May 31st, 2004, 06:22 PM
#6
Thread Starter
New Member
Yes that method works, thanks for your help. I still cannot understand why the error occurs in the first place though!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|