473,394 Members | 1,845 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

XMLDocument 'Save' Method fails with 'Permission Denied'

Hope someone can help with this...

I have looked at all the newsgroup articles and put into practice all
the suggestions but to no good. I am pretty new to CSharp and .Net so
any help would be greatly appreciated.

I have an .ASPX.CS in which I am trying to open an XML file (which
already contains content), making some alterations to the XML obtained
from the file, and then trying to 'Save' the XML back to the file. I
am using a StreamReader object to obtain the XML string from the file,
I then load the XML into an XMLDocument object to make the necessary
changes to the data within the XML. Once that operation is complete I
open a further XMLDocument and load in the altered XML. I then try to
perform a 'Save' operation back to the originating XML file, but it
fails saying 'Access to [XML File Path] is denied'. The File is
opened and saved using HttpContext.Current.Server.MapPath()

I have made sure that ASP.NET has the required permissions on the
file, and I know this works as I can write the file back with a
different filename. Some suggestions on the groups have said to use
'serialization'. To essentially 'serialize' the XML file contents to
an object, make changes to the objects data, and then 'de-serialize'
it to persist it back to the XML file.

Can anyone offer a simple example to do this, and explain why it has
to be this way in order to be able to open, process, and save back an
XML file?

I have tried moving the location of the file to differing folders, and
have tried different names etc.

Many Thanks in advance.

Carl Williams
ca*************@tornadosoftware.net
Nov 16 '05 #1
4 10961
First guess would be that with ntfs the permissions write and change are
two different permission's. If you can create files but not save over
the top of them you might have write access to the file but not
change(modify) access to the file onces it's been created. Easiest way
to test is to give asp.net full control over the file and the path
making sure that the permissions propagate downwards.

Carl Williams wrote:
Hope someone can help with this...

I have looked at all the newsgroup articles and put into practice all
the suggestions but to no good. I am pretty new to CSharp and .Net so
any help would be greatly appreciated.

I have an .ASPX.CS in which I am trying to open an XML file (which
already contains content), making some alterations to the XML obtained
from the file, and then trying to 'Save' the XML back to the file. I
am using a StreamReader object to obtain the XML string from the file,
I then load the XML into an XMLDocument object to make the necessary
changes to the data within the XML. Once that operation is complete I
open a further XMLDocument and load in the altered XML. I then try to
perform a 'Save' operation back to the originating XML file, but it
fails saying 'Access to [XML File Path] is denied'. The File is
opened and saved using HttpContext.Current.Server.MapPath()

I have made sure that ASP.NET has the required permissions on the
file, and I know this works as I can write the file back with a
different filename. Some suggestions on the groups have said to use
'serialization'. To essentially 'serialize' the XML file contents to
an object, make changes to the objects data, and then 'de-serialize'
it to persist it back to the XML file.

Can anyone offer a simple example to do this, and explain why it has
to be this way in order to be able to open, process, and save back an
XML file?

I have tried moving the location of the file to differing folders, and
have tried different names etc.

Many Thanks in advance.

Carl Williams
ca*************@tornadosoftware.net

Nov 16 '05 #2
I'd also check to make sure your StreamReader doesn't still have a ref to
the original file in question. You can run into problems if you haven't
closed the StreamReader before attempting to 'overwrite' the file.

Alex

"Greg Merideth" <be*****@forwardtechnology.net> wrote in message
news:oZ********************@comcast.com...
First guess would be that with ntfs the permissions write and change are
two different permission's. If you can create files but not save over
the top of them you might have write access to the file but not
change(modify) access to the file onces it's been created. Easiest way
to test is to give asp.net full control over the file and the path
making sure that the permissions propagate downwards.

Carl Williams wrote:
Hope someone can help with this...

I have looked at all the newsgroup articles and put into practice all
the suggestions but to no good. I am pretty new to CSharp and .Net so
any help would be greatly appreciated.

I have an .ASPX.CS in which I am trying to open an XML file (which
already contains content), making some alterations to the XML obtained
from the file, and then trying to 'Save' the XML back to the file. I
am using a StreamReader object to obtain the XML string from the file,
I then load the XML into an XMLDocument object to make the necessary
changes to the data within the XML. Once that operation is complete I
open a further XMLDocument and load in the altered XML. I then try to
perform a 'Save' operation back to the originating XML file, but it
fails saying 'Access to [XML File Path] is denied'. The File is
opened and saved using HttpContext.Current.Server.MapPath()

I have made sure that ASP.NET has the required permissions on the
file, and I know this works as I can write the file back with a
different filename. Some suggestions on the groups have said to use
'serialization'. To essentially 'serialize' the XML file contents to
an object, make changes to the objects data, and then 'de-serialize'
it to persist it back to the XML file.

Can anyone offer a simple example to do this, and explain why it has
to be this way in order to be able to open, process, and save back an
XML file?

I have tried moving the location of the file to differing folders, and
have tried different names etc.

Many Thanks in advance.

Carl Williams
ca*************@tornadosoftware.net


Nov 16 '05 #3
Their suggestion is correct, "serialization" security permission should be
enabled for that context. It is needed since the streamreader I believe
demands for this permission to be able to deserialize whatever is in your
xml be it in soap or binary format

"Carl Williams" <ca*************@tornadosoftware.net> wrote in message
news:cc*************************@posting.google.co m...
Hope someone can help with this...

I have looked at all the newsgroup articles and put into practice all
the suggestions but to no good. I am pretty new to CSharp and .Net so
any help would be greatly appreciated.

I have an .ASPX.CS in which I am trying to open an XML file (which
already contains content), making some alterations to the XML obtained
from the file, and then trying to 'Save' the XML back to the file. I
am using a StreamReader object to obtain the XML string from the file,
I then load the XML into an XMLDocument object to make the necessary
changes to the data within the XML. Once that operation is complete I
open a further XMLDocument and load in the altered XML. I then try to
perform a 'Save' operation back to the originating XML file, but it
fails saying 'Access to [XML File Path] is denied'. The File is
opened and saved using HttpContext.Current.Server.MapPath()

I have made sure that ASP.NET has the required permissions on the
file, and I know this works as I can write the file back with a
different filename. Some suggestions on the groups have said to use
'serialization'. To essentially 'serialize' the XML file contents to
an object, make changes to the objects data, and then 'de-serialize'
it to persist it back to the XML file.

Can anyone offer a simple example to do this, and explain why it has
to be this way in order to be able to open, process, and save back an
XML file?

I have tried moving the location of the file to differing folders, and
have tried different names etc.

Many Thanks in advance.

Carl Williams
ca*************@tornadosoftware.net

Nov 16 '05 #4
Thanks a lot for the reply. It came down to permissions on the file in
the end.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Francesc Guim Bernat | last post by:
Dear Colleagues, i'm developing a C++ .NET based application that works with System.Xml library. My problem appears when i try to save a document througt XmlDocument->Save method, because it...
1
by: Francesc Guim Bernat | last post by:
Dear Colleagues, i'm developing a C++ .NET based application that works with System.Xml library. My problem appears when i try to save a document througt XmlDocument->Save method, because it...
2
by: Tom Pearson | last post by:
I have created an XmlDocument and can see that this is correctly formed and has a root element If I Save the doc to a file and reload it all works o If I dump the doc to a stream, again using the...
0
by: Kimon Ifantidis | last post by:
The following error appears when I try to "view in browser" (in Visual Web Developer) a data-driven Web page: SELECT permission denied on object 'Stocks', database 'EzMarket', schema 'dbo'. I...
4
by: zombek | last post by:
I'm making a small program which takes a folder with images and generates optimized normal-sized images and thumbnails using Python Imaging Lbrary (PIL). The problem is here: ........
4
by: MrGado | last post by:
Running on Windows XP with Mozilla 2.0.0.4, I am experiencing a strange security issue. function loadXMLDoc(url,funcname) { try { ...
1
by: doctorhardik | last post by:
other interesting thing i observe during my work which i describe below: i am using dotproject2.0.4 on fc3. it is working fine. but i want to generate pdf file report during this time i face...
0
by: Simo D | last post by:
Hi, I'm using a script.py to write a file in a dir on the server. Mod_python work but i get: Mod_python error: "PythonHandler mod_python.publisher" Traceback (most recent call last): File...
5
by: TimSki | last post by:
Hi, I have an iframe on my page which calls an external website. When the page loads in firefox i see a 'Error: Permission denied to call method Location.toString' in the error console but the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.