473,776 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Cur rent.Server.Map Path()

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************* @tornadosoftwar e.net
Nov 16 '05 #1
4 11008
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.Cur rent.Server.Map Path()

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************* @tornadosoftwar e.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*****@forwar dtechnology.net > wrote in message
news:oZ******** ************@co mcast.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.Cur rent.Server.Map Path()

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************* @tornadosoftwar e.net


Nov 16 '05 #3
Their suggestion is correct, "serializat ion" 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************ *@tornadosoftwa re.net> wrote in message
news:cc******** *************** **@posting.goog le.com...
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.Cur rent.Server.Map Path()

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************* @tornadosoftwar e.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
3256
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 seems to add some strange characters at the beginning of the saved XML document. For instance, if first i print the document throught System::Console class, the output is:
1
2458
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 seems to add some strange characters at the beginning of the saved XML document. For instance, if first i print the document throught System::Console
2
22759
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 Save method, and write this to a file I can then reload this correctly. However since I have no need to write the data to file I want to save it as a stream then reload it the stream. However If I do this I have suddenly lost the root element ...
0
858
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 use Windows authentication and the Web.config file has the following connection string: <connectionStrings>
4
23193
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: ..... os.mkdir(self.output) ..... img = Image.open(os.path.join(self.dir,file)) img = img.resize(self.imgSize) # and here comes the error img.save(self.output, "JPEG", optimize=1)
4
3461
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 { netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); } catch (e) { alert("Permission UniversalBrowserRead denied.");
1
3569
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 permission denied problem. Warning: fopen(/var/www/html/dotproject/files/temp/temp1.pdf): failed to open stream: Permission denied in /var/www/html/dotproject/modules/projects/reports/tasklogs.php on line 307 Could not open file to save PDF. ...
0
1743
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 "/usr/lib64/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch result = object(req)
5
4522
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 page loads nevertheless. I'm assuming therefore this error is 'handled' somehow. In IE7, the page starts to load in the IFRAME and then at the point the same 'Error: Permission denied to call method Location.toString' is detected the page fails to...
0
10117
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10056
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9920
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6721
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5365
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5489
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4027
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3619
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2857
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.