|
|
8000XXXX Errors Alerts ASP.NET 2.0 Classic ASP 1.0 COM / ActiveX Components Forms General Topics Date/Time Routines Email Scripts & Info Files/Directories & FSO Databases General Concepts Search Engine Optimization (SEO)Search | ASP FAQ Tutorials :: Classic ASP 1.0 :: Files/Directories & FSO :: Why do I get an 'Invalid Path Character' error? Why do I get an 'Invalid Path Character' error?In Windows, you can create a folder called c:\who,what\. You can also create a folder with 'bad' characters, e.g. commas, in the name using FileSystemObject (of course, assuming sufficient permissions):
Now, when I try to do the following, I get an error:
What's up with that? Here is the error I receive:
The initial response I received from Microsoft was that the path passed to MapPath was perhaps 'protected' due to possible conflicts with URLEncode or HTMLEncode. I commented that a comma is a perfectly valid URL and HTML character, and that neither Server.URLEncode nor Server.HTMLEncode really altered its appearance. They said they'd keep digging, and that they might even have to look at the code (gasp!). So, while we wait for an official response, which I'm promised is forthcoming, I can suggest a workaround. Namely, use Server.MapPath() to obtain the root, and then build out using "local" folder paths. For example:
While I'm not optimistic this limitation of classic ASP will ever get fixed, I have to assert that if I can create a folder with certain characters in the name in Windows or using FileSystemObject, I should be able to get the path of that folder using Server.MapPath. FWIW, here are the characters that cause the Server.MapPath method to fail:
Another case where you may come across this problem is something like the following:
This is because server.transfer internally performs a server.mappath() (for some reason), and it can't take the ? character... For whatever it's worth, I couldn't get & to fail on a server.mappath call, using Windows 2003 Server. However it is listed above because others have reported it as being an issue (I imagine on earlier server versions, or maybe a client OS like Windows 98). Related Articles Can I include a file in both server-side and client-side script? Can I read / write a user's file without a prompt? Can I rename a file using FileSystemObject? Could I get some help working with files using FileSystemObject? How do I avoid 'the red x' when an image is missing? How do I change the modified time of a file? How do I create / manipulate images from ASP? How do I dynamically include files? How do I find the owner, author, and other properties of a file? How do I get a list of a folder's subfolders? How do I get the name of the current URL / page? How do I prevent people from 'leeching' my CSS or JS files? How do I prevent people from 'leeching' my images? How do I retrieve a random file from a given folder? How do I send the correct filename with BinaryWrite? How do I sort a list of files? How do I use FileSystemObject to create a file on the client? Why do I get 'Disk not ready' errors with FileSystemObject? Why do I get 'Invalid procedure call or argument'? Why do I get 'Path not found' errors with Scripting.FileSystemObject? Why do I get 'Permission Denied' errors with FileSystemObject? Why do I get 800A0034 errors? Why do I get 800A003E / Input past end of file errors? Why do I get 800A0BBA errors? Why do I get 800A0BBC errors? Why do I get permissions errors after upgrading to Windows XP? Why does FileSystemObject hang all of a sudden? Why is 'the operation completed successfully' an error message? |