G
Guest
Hi all,
I want read some data stored in XML document in my aspx page, but I have
problem with this.
My XML file settings.xml is:
<?xml version="1.0" encoding="utf-8" ?>
<parameters>
<back_color>blue</back_color>
<text_color>red</text_color>
</parameters>
And here is part of my aspx. page source:
void ReadIniParameteters()
{
XmlTextReader reader = null;
String args = "ini/settings.xml";
try
{
reader = new XmlTextReader (args); // here it is OK
while (reader.Read()) // and here occures an error
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
Response.Write(reader.Value);
break;
}
}
}
catch (Exception e)
{
Response.Write("Failed to read the file");
Response.Write("Exception: " + e.ToString());
}
finally
{
Response.Write("Processing of the file complete.");
if (reader != null)
reader.Close();
}
}
When I run this code an error occures:
Failed to read the fileException: System.IO.DirectoryNotFoundException:
Could not find a part of the path "C:\WINDOWS\system32\ini\settings.xml". at
System.IO.__Error.WinIOError(Int32 errorCode, String str) at
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean
bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode,
FileAccess access, FileShare share) at
System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials) at
System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type
ofObjectToReturn)
What I'm doing wrong? Please help me.
Tomas
I want read some data stored in XML document in my aspx page, but I have
problem with this.
My XML file settings.xml is:
<?xml version="1.0" encoding="utf-8" ?>
<parameters>
<back_color>blue</back_color>
<text_color>red</text_color>
</parameters>
And here is part of my aspx. page source:
void ReadIniParameteters()
{
XmlTextReader reader = null;
String args = "ini/settings.xml";
try
{
reader = new XmlTextReader (args); // here it is OK
while (reader.Read()) // and here occures an error
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
Response.Write(reader.Value);
break;
}
}
}
catch (Exception e)
{
Response.Write("Failed to read the file");
Response.Write("Exception: " + e.ToString());
}
finally
{
Response.Write("Processing of the file complete.");
if (reader != null)
reader.Close();
}
}
When I run this code an error occures:
Failed to read the fileException: System.IO.DirectoryNotFoundException:
Could not find a part of the path "C:\WINDOWS\system32\ini\settings.xml". at
System.IO.__Error.WinIOError(Int32 errorCode, String str) at
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean
bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode,
FileAccess access, FileShare share) at
System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials) at
System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type
ofObjectToReturn)
What I'm doing wrong? Please help me.
Tomas