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

"Illegal characters in path" with XmlReader of .Net 1.1

I only found one post on Google where someone mentions the same problem
with a DataSet:

XmlDataReader in .Net 1.1 can not read XML files from a path which
contains "%10" or "%3f".

code to reproduce:

string filename = "%10.xml"; //XML file with this name is existing
XmlReader reader = new XmlTextReader(filename);
reader.Read();

this will throw an
System.ArgumentException: "Illegal characters in path."
at System.IO.Path.CheckInvalidPathChars(String path)
at System.IO.Path.GetFileName(String path)
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)
at System.Xml.XmlTextReader.CreateScanner()
at System.Xml.XmlTextReader.Init()
at System.Xml.XmlTextReader.Read()
All classes which use the XmlReader internally have the same problem
(DataSet, XmlDocument, ...), but XmlWriter can write to such a file.

This bug is fixed in .Net 2.0, and in 1.1 the workaround is simply to
first load the file into a streamreader:

IO.StreamReader streamReader = new StreamReader(filename);
XmlReader reader = new XmlTextReader(streamReader);
....

What really interests me is:
- Why can't I find any info about this behaviour on MSDN? This would
have saved us from shipping a product which falls over "%" in the filename.
As our product is for chemists, the probability of choosing this
character in a file or directory name is not so low as one might expect
from "normal" usage: "EtOH60%10ml_method" beeing one example.
- What is so special about "%10" or "%3f" ? Are there other
"problematic" charater combinations?

as a sidenote:
If I try to add a file to a Solution in Visual Studio 2005 it tells me:
Item and file names cannot:
- contain any of the following characters: / ? : & \ * " < > | # %

Since when are "#" or "%" invalid characters in the windows file system?

Eckhard
Apr 28 '06 #1
3 15750
* Eckhard Schwabe wrote in microsoft.public.dotnet.xml:
I only found one post on Google where someone mentions the same problem
with a DataSet:

XmlDataReader in .Net 1.1 can not read XML files from a path which
contains "%10" or "%3f".
To clarify, does the path include the string "%3f" or does it include
the string "?"? In case of the former you have to URL-escpae the path
before passing it here, System.Uri has methods for that. "%253f" would
be the right string in this case.
What really interests me is:
- Why can't I find any info about this behaviour on MSDN? This would
have saved us from shipping a product which falls over "%" in the filename.
As our product is for chemists, the probability of choosing this
character in a file or directory name is not so low as one might expect
from "normal" usage: "EtOH60%10ml_method" beeing one example.
The documentation is rather clear that the arguments are URLs, not file
names. There is some overlap, but in cases like this the difference is
important.
- What is so special about "%10" or "%3f" ? Are there other
"problematic" charater combinations?


These map to U+0010 and U+003F, a control character and the question
mark. RFC 3986 has the details.
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Apr 29 '06 #2
>> XmlDataReader in .Net 1.1 can not read XML files from a path which
contains "%10" or "%3f".
To clarify, does the path include the string "%3f" or does it include
the string "?"?


It includes "%3f".
"?" is an illegal character for a path, so this wouldn't be a bug.
In case of the former you have to URL-escpae the path
before passing it here, System.Uri has methods for that. "%253f" would
be the right string in this case.
I don't understand what you mean.
The documentation is rather clear that the arguments are URLs, not file
names. There is some overlap, but in cases like this the difference is
important.
And why has DotNet 2.0 no problems with the same file name?
From the Documentation for "DataSet.ReadXml" (which had the same
problem in DotNet 1.1):
DataSet.ReadXml (String) Reads XML schema and data into the DataSet
using the specified file.


So it clearly states: "file", not "URL".
- What is so special about "%10" or "%3f" ? Are there other
"problematic" charater combinations?


These map to U+0010 and U+003F, a control character and the question
mark. RFC 3986 has the details.


So DotNet 1.1 erroneously translated "%3f" to a question mark, which IS
an invalid character before trying to open the file. The bug was perhaps
in "Urlresolver class"?

Regards,

Eckhard
Apr 30 '06 #3
* Eckhard Schwabe wrote in microsoft.public.dotnet.xml:
In case of the former you have to URL-escpae the path
before passing it here, System.Uri has methods for that. "%253f" would
be the right string in this case.
I don't understand what you mean.


URLs use %xx as escape sequence for special characters. The '%'
character is a special character that has to be escaped if it is
not part of such an escape sequence. %25 is the escape sequence
for the '%' character, %3f is the escape sequence for the '?'
character.
And why has DotNet 2.0 no problems with the same file name?
The argument is not a file name. .NET 2.0 presumably has code to
work around authoring errors like this.
So it clearly states: "file", not "URL".


It would be good if you could file a documentation bug report on
this then, e.g. using the "Send comments" link on the MSDN page.
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Apr 30 '06 #4

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

Similar topics

0
by: BenO | last post by:
Hi I'm new to python and need to write a function to replace certain characters in a string (html). The characters I need to replace come from MS Word copy & paste and are: ' (Left quote)...
2
by: qe_Cui | last post by:
Hello everyone: I am using vb.net 2003, sqlserver2000 database, and windows 2000 professional OS. In the program, I encrypt the login user's userid and passed with RSACryptoServiceProvider....
1
by: Norbert Munkel | last post by:
Hi, System: 8.1.5 UDB on SuSE Linux I created a new SMS tablespace with following ddl: CREATE REGULAR TABLESPACE ASNCTL IN DATABASE PARTITION GROUP IBMDEFAULTGROUP PAGESIZE 4096 MANAGED BY...
2
by: Karl Koscher | last post by:
I'm trying to communicate with a USB device using C#. I'm able to determine the device path using P/Invoke and SetupDiGetClassDevs, SetupDiEnumDeviceInterfaces, and SetupDiGetDeviceInterfaceDetail,...
3
by: Arpi Jakab | last post by:
I have a main project that depends on projects A and B. The main project's additional include directories list is: ...\ProjectA\Dist\Include ...\ProjectB\Dist\Include Each of the include...
1
by: Steve Grahovac | last post by:
I have been having trouble the last few days opening any ASP.NET web forms in the design view in the designer. Every time I clicked on an aspx file I got a message box with the error "Unable to...
1
by: Shilpa | last post by:
Hi, I have a OpenFileDialog on my windows form whose filter is *.*. I want the users to be able to further filter the files by giving *.doc or *.zip etc in the "file name" field of the dialog...
1
by: cppcompiler1000 | last post by:
when i was writing a program i got an error of " illegal structure operation" , in which situation compiler gives this type of error?
0
by: Malith Wickrama | last post by:
Hi, I have to send an XML file to a web url with an HTTP POST. This XML file does contain an audio clip that has been converted into base64 file format. Before I send this file as an HTTP POST I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
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,...

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.