Re: XMLDocument 'Save' Method fails with 'Permission Denied'

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Joey Calisay (joeycalisay_at_yahoo.com)
Date: 09/16/04


Date: Thu, 16 Sep 2004 23:32:50 +0800

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" <carl.e.williams@tornadosoftware.net> wrote in message
news:cc4be67a.0409160722.9110cf8@posting.google.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.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
> carl.e.williams@tornadosoftware.net



Relevant Pages

  • Re: Request for permission type failed
    ... In order to give your program the permissions you need, go to the .NET Administration applet and add a new permission set that corresponds to your application. ... DataGridView are read and writen to the .XML using DataSet.ReadXml ... StackCrawlMark& stackMark, Boolean isPermSet) ... access, Int32 rights, Boolean useRights, FileShare share, Int32 ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Incorrect XML returned
    ... the JOIN clause looks a little odd to me. ... FOR XML AUTO ... UserGroupID int) ... (1, 1, 'Test Permission') ...
    (microsoft.public.sqlserver.xml)
  • Re: problem with special characters in file command?
    ... xml and wav files are listed when you glob the directory but that when ... you execute file readable on the xml file, ... is correct assuming that you do not have read permission for that ...
    (comp.lang.tcl)
  • Re: problem with special characters in file command?
    ... I'm not convinced there is a Tcl error here. ... you execute file readable on the xml file, ... is correct assuming that you do not have read permission for that ...
    (comp.lang.tcl)
  • Re: how to get this code to do exactly what I want ??
    ... I want to change Untitled Ad at the top of the xml to the name of the ... etn advertiser name in this xml for example LEAF GUARD OF LAKE ERIE ... foreach (string fileName in myFiles) ... StreamReader myStream = new ...
    (microsoft.public.dotnet.languages.csharp)