473,890 Members | 1,416 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"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(f ilename);
reader.Read();

this will throw an
System.Argument Exception: "Illegal characters in path."
at System.IO.Path. CheckInvalidPat hChars(String path)
at System.IO.Path. GetFileName(Str ing path)
at System.IO.FileS tream..ctor(Str ing path, FileMode mode, FileAccess
access, FileShare share)
at System.Xml.XmlD ownloadManager. GetStream(Uri uri, ICredentials
credentials)
at System.Xml.XmlU rlResolver.GetE ntity(Uri absoluteUri, String role,
Type ofObjectToRetur n)
at System.Xml.XmlT extReader.Creat eScanner()
at System.Xml.XmlT extReader.Init( )
at System.Xml.XmlT extReader.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(fi lename);
XmlReader reader = new XmlTextReader(s treamReader);
....

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_me thod" beeing one example.
- What is so special about "%10" or "%3f" ? Are there other
"problemati c" 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 15804
* Eckhard Schwabe wrote in microsoft.publi c.dotnet.xml:
I only found one post on Google where someone mentions the same problem
with a DataSet:

XmlDataReade r 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_me thod" 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****@h oehrmann.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.ReadXm l" (which had the same
problem in DotNet 1.1):
DataSet.ReadXm l (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
"problemati c" 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 "Urlresolve r class"?

Regards,

Eckhard
Apr 30 '06 #3
* Eckhard Schwabe wrote in microsoft.publi c.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****@h oehrmann.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
1719
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) ' (Right quote) Double Left quotes
2
2426
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. It is work fine in my compute, but when i set up it on the client computer(which have assembled IE6.0 SP1, ..net framework 1.1 and MDAC 2.7. and the
1
3631
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 SYSTEM USING ('/data/db2/db2inst1/ASNCTL') EXTENTSIZE 32
2
10844
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, but I can't open the device using File.Open. I get the following error: An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll Additional information: Illegal characters in path.
3
2719
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 directories contain a file named "cppfile1.h". In my main project I #include "cppfile1.h". I rely on the order of paths in additional include directories list to get file cppfile1.h from ProjectA and
1
5438
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 open in designer. Illegal characters in path" and the file is instead opened in HTML view. I don't know what application or situation may have caused this error. I looked on the newsgroups and noticed that numerous other people were having this...
1
2340
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 (Just like it happens in the open file dialog of MS Word) Currently, if the user enters a wild card character in the file name field, it is throwing an exception with the message "Illegal characters in path". Please let me know how to achieve the...
1
6978
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
1650
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 have to convert this to string. When I try to convert the file to a string it gives me an exception. private string GetTextFromXMLFile(string filePath) { try { StreamReader streamReader = new StreamReader ...
0
9979
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9826
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10925
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10468
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7171
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5854
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6058
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4682
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3282
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.