DataSet.WriteXml refuses to write...

R

Rainer Queck

Hi NG,

I have no idea why, but since a while a dataset refuses to write to a
specific xml file.
I get the error message "Der Zugriff auf den Pfad
D:\VS2005Projects\BfpNet\BfpNet\bin\Debug\Bfp.xml wurde verweigert" which
translates to:
"The access to the path D:\VS...... was denied".

The dataset can read from this Bfp.xml without any problems.
The file has no read only flag set or any thing else I can identify as a
cause to this problem.
If I read the xml, set a breakpoint shortly before I write to it again,
delete the file, ds.WriteXml works fine from then on. Now I can start/stop
my app and modify the xml, read write it as often as I want, I have no more
problems.

So why cant I write to the original xml?

Thanks for hints and help.

Regards
Rainer Queck
 
J

Jon Skeet [C# MVP]

So why cant I write to the original xml?

Sounds like you might still have the file open for reading. What
happens if you write to a different file (in the same directory) out
of interest? Or write to the file with an empty dataset (i.e. not
having read from it)?

Jon
 
C

Chris Shepherd

Rainer said:
Hi NG,

I have no idea why, but since a while a dataset refuses to write to a
specific xml file.
I get the error message "Der Zugriff auf den Pfad
D:\VS2005Projects\BfpNet\BfpNet\bin\Debug\Bfp.xml wurde verweigert" which
translates to:
"The access to the path D:\VS...... was denied".

The dataset can read from this Bfp.xml without any problems.
The file has no read only flag set or any thing else I can identify as a
cause to this problem.
If I read the xml, set a breakpoint shortly before I write to it again,
delete the file, ds.WriteXml works fine from then on. Now I can start/stop
my app and modify the xml, read write it as often as I want, I have no more
problems.

So why cant I write to the original xml?

Are the following true?

- The file is not currently in use/locked by some other (or the same)
application.
- The user trying to write to xml file has permissions to write to it.
- The path in the error message is correct.


Chris.
 
G

Guest

Perhaps the reference to the original file is still 'locked' because it
hasn't been garbage collected yet? Do you need to call .Dispose() on the
file?

Perhaps post your code?
 
R

Rainer Queck

Hi Jon,
Sounds like you might still have the file open for reading. What
happens if you write to a different file (in the same directory) out
of interest? Or write to the file with an empty dataset (i.e. not
having read from it)?
This is what I ment (and did) as I wrote :
If I read the xml, set a breakpoint shortly before I write to it again,
delete the file, ds.WriteXml works fine from then on. Now I can start/stop
my app and modify the xml, read write it as often as I want, I have no more
problems.
<==
I can create me a new Bfp.xml, and have no more problems with reading and
writing to it.

Regards
Rainer
 
R

Rainer Queck

Hi Chris,

Chris Shepherd said:
Are the following true?

- The file is not currently in use/locked by some other (or the same)
application.
Yes. If I delete the old bfp.xml and create me a new one, I have no more
problems with it.
- The user trying to write to xml file has permissions to write to it.
This is the big question. How can I find out?
- The path in the error message is correct.
Yes.

Regards
Rainer
 
R

Rainer Queck

Perhaps the reference to the original file is still 'locked' because it
hasn't been garbage collected yet? Do you need to call .Dispose() on the
file?
That would not explain, why it works, if I create me a new Bfp.xml and use
that from then on, because if I do so my problems are gone.
Perhaps post your code?
Difficult, because too much.
But I am only using <DataSet>.ReadXml and <DataSet>.WriteXml to acces the
xml file.

Regards
Rainer
 
C

Chris Shepherd

Rainer said:
Hi Chris,


Yes. If I delete the old bfp.xml and create me a new one, I have no more
problems with it.

This is the big question. How can I find out?

Right click the file, go Properties, and then look at the Security tab.
This is assuming Windows XP Professional, Windows 2000 (any), Windows
2003, or Windows Vista.

Chris.
 
R

Rainer Queck

there is no security tab.
FYI I am working with XP-Professional.
I know the security can be set "some where", but where?

Regards
Rainer
 
J

Jon Skeet [C# MVP]

This is what I ment (and did) as I wrote :


If I read the xml, set a breakpoint shortly before I write to it again,
delete the file, ds.WriteXml works fine from then on. Now I can start/stop
my app and modify the xml, read write it as often as I want, I have no more
problems.
<==
I can create me a new Bfp.xml, and have no more problems with reading and
writing to it.

So how do you get back from that situation to having problems again?

Jon
 
R

Rainer Queck

Hi Jon,

Jon Skeet said:
So how do you get back from that situation to having problems again?
By reverting the SnapShot off my VMWare virtual machine ;-)

To be honest, I cant get back to the problem state now unless I do a revert
of my snapshot.
The problem is solved if I create a new bfp.xml. But it worries me, that
this can happen later on, when one of my customers will use the software.
That is why I want to locate the cause to my problem.

Regards
Rainer
 
J

Jon Skeet [C# MVP]

Rainer Queck said:
By reverting the SnapShot off my VMWare virtual machine ;-)

To be honest, I cant get back to the problem state now unless I do a revert
of my snapshot.
The problem is solved if I create a new bfp.xml. But it worries me, that
this can happen later on, when one of my customers will use the software.
That is why I want to locate the cause to my problem.

That sounds like it's a permissions issue then.
 
W

Walter Wang [MSFT]

Hi Rainer,

I would suggest to use Process Monitor
(http://www.microsoft.com/technet/sysinternals/processesandthreads/processmo
nitor.mspx) or FileMon
(http://www.microsoft.com/technet/sysinternals/FileAndDisk/Filemon.mspx) to
monitor the xml file and see if any other processes are accessing it too.

I'm not sure if it's related to ds.ReadXml(), but you could create a copy
of the xml first and call ds.ReadXml() on the copy; later call
ds.WriteXml() on the original one. This could isolate if the issue is
related to ReadXml() or not.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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