473,406 Members | 2,387 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,406 software developers and data experts.

Problem with saving an XML file

Hi,

I am trying to write to an Xml document. My xml file is present is in the
current working directory but whenever i try to make changes to the file and
save the change in the XML file (which i specify as a parameter to
doc.Save() method) it searches for the file in F:/WINNT/System32 folder...

Even if I specify the path explicitly to
"F:\Inetpub\wwwroot\WebApplication4\UserPass.x ml" it gives an error.

I have specified the code below.

May I know if there is any way by which I nee to set the default path to my
current directory.

XmlDocument doc = new XmlDocument();

string url="http://localhost/WebApplication4/UserPass.xml";

doc.Load(url);

//Add table tag

XmlElement table = doc.CreateElement("Table");
//Add username tag and text

XmlElement xusername = doc.CreateElement("username");

XmlText usrtxt = doc.CreateTextNode(myusername);

//Save the xml document

string filename = "WebApplication4\\UserPass.xml";

string filepath = Path.GetFullPath(filename);
doc.Save(filepath);
Nov 12 '05 #1
3 3191
hi smitha
use Server.MapPath("Filename")

regards
Jagadeesh
"smita" <sm***@rarefind.com> wrote in message
news:eI**************@TK2MSFTNGP12.phx.gbl...
Hi,

I am trying to write to an Xml document. My xml file is present is in the current working directory but whenever i try to make changes to the file and save the change in the XML file (which i specify as a parameter to
doc.Save() method) it searches for the file in F:/WINNT/System32 folder...
Even if I specify the path explicitly to
"F:\Inetpub\wwwroot\WebApplication4\UserPass.x ml" it gives an error.

I have specified the code below.

May I know if there is any way by which I nee to set the default path to my current directory.

XmlDocument doc = new XmlDocument();

string url="http://localhost/WebApplication4/UserPass.xml";

doc.Load(url);

//Add table tag

XmlElement table = doc.CreateElement("Table");
//Add username tag and text

XmlElement xusername = doc.CreateElement("username");

XmlText usrtxt = doc.CreateTextNode(myusername);

//Save the xml document

string filename = "WebApplication4\\UserPass.xml";

string filepath = Path.GetFullPath(filename);
doc.Save(filepath);

Nov 12 '05 #2
use Server.MapPath(filename);

"smita" <sm***@rarefind.com> wrote in message
news:eI**************@TK2MSFTNGP12.phx.gbl...
Hi,

I am trying to write to an Xml document. My xml file is present is in the current working directory but whenever i try to make changes to the file and save the change in the XML file (which i specify as a parameter to
doc.Save() method) it searches for the file in F:/WINNT/System32 folder...
Even if I specify the path explicitly to
"F:\Inetpub\wwwroot\WebApplication4\UserPass.x ml" it gives an error.

I have specified the code below.

May I know if there is any way by which I nee to set the default path to my current directory.

XmlDocument doc = new XmlDocument();

string url="http://localhost/WebApplication4/UserPass.xml";

doc.Load(url);

//Add table tag

XmlElement table = doc.CreateElement("Table");
//Add username tag and text

XmlElement xusername = doc.CreateElement("username");

XmlText usrtxt = doc.CreateTextNode(myusername);

//Save the xml document

string filename = "WebApplication4\\UserPass.xml";

string filepath = Path.GetFullPath(filename);
doc.Save(filepath);

Nov 12 '05 #3
Smita,

I assume your code relies in a Web Application. Therefore you should use Server.MapPath("yourFileName.xml") service to obtain the actual physical path for yourFileName.xml file which is included in the same folder with the ASP .NET web page that executes the code. (The "current folder" is not usable in ASP .NET Web Applications since they are run with ASPNET user credentials in the IIS process, and the system current folder for that process is, as you noticed, the System folder of your operating system).

--
Sorin Dolha [MCP, MCAD]
"smita" <sm***@rarefind.com> wrote in message news:eI**************@TK2MSFTNGP12.phx.gbl...
Hi,

I am trying to write to an Xml document. My xml file is present is in the
current working directory but whenever i try to make changes to the file and
save the change in the XML file (which i specify as a parameter to
doc.Save() method) it searches for the file in F:/WINNT/System32 folder...

Even if I specify the path explicitly to
"F:\Inetpub\wwwroot\WebApplication4\UserPass.x ml" it gives an error.

I have specified the code below.

May I know if there is any way by which I nee to set the default path to my
current directory.

XmlDocument doc = new XmlDocument();

string url="http://localhost/WebApplication4/UserPass.xml";

doc.Load(url);

//Add table tag

XmlElement table = doc.CreateElement("Table");
//Add username tag and text

XmlElement xusername = doc.CreateElement("username");

XmlText usrtxt = doc.CreateTextNode(myusername);

//Save the xml document

string filename = "WebApplication4\\UserPass.xml";

string filepath = Path.GetFullPath(filename);
doc.Save(filepath);
Nov 12 '05 #4

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

Similar topics

6
by: Zaan | last post by:
www.entropy.ch release for Mac OS X.] Hello, My issue is the following: to promote consistency on a site I'm building, I decided to go for a php scheme where some recurring elements...
11
by: Richard Muller | last post by:
Hi, I new to ASP. I have a problem with an ASP script opening a file for writing on my server. Here's how I got to this error: I downloaded a neat FileUpload ASP example from...
13
by: Bob Darlington | last post by:
I have a repair and backup database routine which runs when a user closes down my application. It works fine in my development machine, but breaks on a client's at the following line: If...
3
by: Kidus Yared | last post by:
I am having a problem displaying Unicode characters on my Forms labels and buttons. After coding Button1.Text = unicode; where the unicode is a Unicode character or string (‘\u1234’ or...
4
by: dale zhang | last post by:
Hi, I am trying to save and read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp Right now, I saved images without any...
5
by: Karl | last post by:
Hi, I have some code that will save the contents of a Rich Text Box in either a Text or Rich Text Format file. The code is using the SaveFileDialog and is working correctly. I have been...
5
by: IkBenHet | last post by:
Hello, I use this script to upload image files to a folder on a IIS6 server: ******************* START UPLOAD.ASPX FILE ********************** <%@ Page Language="VB" Debug="true" %>
7
by: Nathan Sokalski | last post by:
I am having a problem saving an image with the same name it originally had. I have two similar versions of my code, one in which I close the FileStream used to open the original image before saving,...
0
by: Waqas.L.Khan | last post by:
Hi guys, I have a problem when trying to create an image file. Basically my code takes any file and gets it's system icon using SHGetFileInfo and then saves the file either by converting it into...
2
by: Rene | last post by:
Hello to all! I am a newbee to C++, I did a beginners' course, and now I am stuck with a strange problem. I have written the function that is pasted downwards. The peculiar thing is that when...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.