Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i ahve eeror in this code any one solve this error plz its urgent.............




this is my aspx.cs code..........

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        XmlTextReader reader = new XmlTextReader("C:\\Documents and Settings\azhar\\Desktop");
        XmlNodeType type;
        while (reader.Read())

        {
            type = reader.NodeType;
            if (type == XmlNodeType.Element)
            {

                if (reader.Name == "NMBM Test")
                {
                    reader.Read();
                    ListBox1.Items.Add(reader.Value);
                }
            }
            reader.Close();
        }
    }
}


and this is my XMLFile.xml code...........


XML
<?xml version="1.0" encoding="utf-8" ?>
<DocumentElement>
   <Location>
    <id>NMBM Test</id>
    <DataBaseName>ICMAStest</DataBaseName>
    <WebServerName>ICMAS-TEST</WebServerName>
    <DataBaseServerName>ICMAS-TEST\SQLEXPRESS</DataBaseServerName>
    <ClientSettingsProvider.ServiceUri />
    <RptUrl>http://icmas-test/ReportServer_SQLEXPRESS</RptUrl>
    <ReportPath>/ICMASReports/</ReportPath>
    <ReportServerUserName>NALIN</ReportServerUserName>
    <ReportServerPassword>temp123</ReportServerPassword>
    <SMTPServerId>10.100.0.80</SMTPServerId>
  </Location>
   <Location>
    <id>NMBM Production</id>
    <DataBaseName>ICMAStest</DataBaseName>
    <WebServerName>ICMAS-TEST</WebServerName>
    <DataBaseServerName>ICMAS-TEST\SQLEXPRESS</DataBaseServerName>
    <ClientSettingsProvider.ServiceUri />
    <RptUrl>http://icmas-test/ReportServer_SQLEXPRESS</RptUrl>
    <ReportPath>/ICMASReports/</ReportPath>
    <ReportServerUserName>NALIN</ReportServerUserName>
    <ReportServerPassword>temp123</ReportServerPassword>
    <SMTPServerId>10.100.0.80</SMTPServerId>
  </Location>
   <Location>
    <id>ICMASDev Satish</id>
    <DataBaseName>ICMAStest</DataBaseName>
    <WebServerName>192.168.0.178</WebServerName>
    <DataBaseServerName>epmpune\ciodevdb</DataBaseServerName>
    <ClientSettingsProvider.ServiceUri />
    <RptUrl>http://icmas-test/ReportServer_SQLEXPRESS</RptUrl>
    <ReportPath>/ICMASReports/</ReportPath>
    <ReportServerUserName>NALIN</ReportServerUserName>
    <ReportServerPassword>temp123</ReportServerPassword>
    <SMTPServerId>10.100.0.80</SMTPServerId>
  </Location>
   <Location>
    <id>ICMAS Test icmastest-userpc2</id>
    <DataBaseName>ICMASQA</DataBaseName>
    <WebServerName>userpc2</WebServerName>
    <DataBaseServerName>epmpune\ciodevdb</DataBaseServerName>
    <ClientSettingsProvider.ServiceUri />
    <RptUrl>http://userpc2/ReportServer_SQLEXPRESS</RptUrl>
    <ReportPath>/userpc2/</ReportPath>
    <ReportServerUserName>NALIN</ReportServerUserName>
    <ReportServerPassword>temp123</ReportServerPassword>
    <SMTPServerId>mail.24by7cio.com</SMTPServerId>
  </Location>
   <Location>
    <id>ICMASQA</id>
    <DataBaseName>ICMASQA</DataBaseName>
    <WebServerName>192.168.0.178</WebServerName>
    <DataBaseServerName>epmpune\ciodevdb</DataBaseServerName>
    <ClientSettingsProvider.ServiceUri />
    <RptUrl>http://userpc2/ReportServer_SQLEXPRESS</RptUrl>
    <ReportPath>/userpc2/</ReportPath>
    <ReportServerUserName>NALIN</ReportServerUserName>
    <ReportServerPassword>temp123</ReportServerPassword>
    <SMTPServerId>mail.24by7cio.com</SMTPServerId>
  </Location>
</DocumentElement>



error........

Server Error in '/WebSite25' Application.
Illegal characters in path.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Illegal characters in path.

Source Error:

Line 17: XmlTextReader reader = new XmlTextReader("C:\\Documents and Settings\azhar\\Desktop");
Line 18: XmlNodeType type;
Line 19: while (reader.Read())
Line 20:
Line 21: {
Posted
Updated 24-Feb-12 20:47pm
Comments
Chuck N0rris 25-Feb-12 2:33am    
1) Avoid txtSpeak. Type please instead of plz.
2) Don't put urgent or ASAP in your question.
3) Put your code in code-block
4) Also fix the typos if possible(Browser will show you the spelling errors in red underline).
5) Update your question using Improve Question link

I don't have power to do these :sigh:

The error message is pretty clear:
"Illegal characters in path."

Now, all you have to do is look at the line that is reporting the error and the problem should leap out at you.

I would point it out, since it is so simple and clear, but since you persist in yelling "URGENT" for everything, despite having been told it is a bad idea, I won't.

I'll give you a clue though: Look to the left of each character in the path - play spot the difference!
 
Share this answer
 
Comments
rockpune 25-Feb-12 2:46am    
sorry sir but am unable to find that error tell me sir
rockpune 25-Feb-12 2:47am    
Illegal characters in path.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Illegal characters in path.

Source Error:

Line 17: XmlTextReader reader = new XmlTextReader("C:\\Documents and Settings\azhar\\Desktop\appsettings.xml");
Line 18: XmlNodeType type;
Line 19: while (reader.Read())
Line 20:
Line 21: {
OriginalGriff 25-Feb-12 3:06am    
1) Look at the line it is complaining about.
2) Look at what it says is wrong.
3) Spot the difference in the line.
4) It is so obvious. Look at each character individually, and compare it to the one to its right and left if you have to.
5) Stop yelling "URGENT" with every question. It may be to you, but it isn't to us.
Just change your
C#
XmlTextReader reader = new XmlTextReader("C:\\Documents and Settings\azhar\\Desktop\appsettings.xml");

this line to
C#
XmlTextReader reader = new XmlTextReader("C:\\Documents and Settings\\azhar\\Desktop\\appsettings.xml");

You were just missing a back-slash(\).
Else use
C#
XmlTextReader reader = new XmlTextReader(@"C:\Documents and Settings\azhar\Desktop\appsettings.xml");

to avoid mistakes!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900