473,756 Members | 3,663 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Path.InvalidPat hChars question

Hi !
I have determined, that Path.InvalidPat hChars does not return an array
with all invalid path characters. For instance the question mark (?)
does not appear in the array, but it is not possible to create a folder
with a question mark (?).

How can I get the whole range of invalid path characters ? Or is it the
best way, to create a folder and using try/catch ?

Regards

Nov 23 '06 #1
3 5993
You should try catch it as it isnt garunteed to work even with a good name as
permissions or name clashes could still get in the way. Plus it may change in
future OS's. Spaces didnt used to be allowed in windows.

Ciaran O'Donnell

"schaf" wrote:
Hi !
I have determined, that Path.InvalidPat hChars does not return an array
with all invalid path characters. For instance the question mark (?)
does not appear in the array, but it is not possible to create a folder
with a question mark (?).

How can I get the whole range of invalid path characters ? Or is it the
best way, to create a folder and using try/catch ?

Regards

Nov 23 '06 #2

schaf wrote:
Hi !
I have determined, that Path.InvalidPat hChars does not return an array
with all invalid path characters. For instance the question mark (?)
does not appear in the array, but it is not possible to create a folder
with a question mark (?).
Hi,
MSDN: This array (InvalidPathCha rs) is not guaranteed to contain the
complete set of characters that are invalid in file and directory
names. The full set of invalid characters can vary by file system...
>
How can I get the whole range of invalid path characters ? Or is it the
best way, to create a folder and using try/catch ?

Regards
Alternative way is to leave in the path name only exactly valid
characters instead of looking for possible invalid ones.
Ex.:
string path = @"c:\\test\d f ?sdg\1.txt";
System.Text.Reg ularExpressions .Regex re = new
System.Text.Reg ularExpressions .Regex(@"[^\w\\:.]+");
path = re.Replace(path , "");
Maybe it helps somehow.

Nov 23 '06 #3
Hi marss
Alternative way is to leave in the path name only exactly valid
characters instead of looking for possible invalid ones.
Ex.:
string path = @"c:\\test\d f ?sdg\1.txt";
System.Text.Reg ularExpressions .Regex re = new
System.Text.Reg ularExpressions .Regex(@"[^\w\\:.]+");
path = re.Replace(path , "");
Maybe it helps somehow.
I have a similar alternative way, I do not want to update my regex or
char-array, each time the user changes the OS. And I'm not sure, if the
chinese version of windows has the same invalid character like a german
or english windows.

Nov 23 '06 #4

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

Similar topics

14
2639
by: Thomas Heller | last post by:
I was trying to track down a bug in py2exe where the executable did not work when it is in a directory containing japanese characters. Then, I discovered that part of the problem is in the zipimporter that py2exe uses, and finally I found that it didn't even work in Python itself. If the entry in sys.path contains normal western characters, umlauts for example, it works fine. But when I copied some japanese characters from a random...
20
17046
by: Webdad | last post by:
Hi! I running my first year as industrial engineer (informatics) We have an assignment to do : .... create a playfield (matrix). Some places in that field are blocked, so you can't pass them. The others are free to go over ... (I already found that part) -> http://users.pandora.be/hebbrecht/jochen/c++/test.cpp
2
10832
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.
6
2586
by: I am Sam | last post by:
I keep getting this error and I don't know why: The path is too long after being fully qualified. Make sure path is less than 260 characters. 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.IO.PathTooLongException: The path is too long
2
3880
by: Seth | last post by:
Ok, here is my setup. I have a fully functioning HTTP Handler implemented. The handler is supposed to handle every single request that comes in to a particular virtual directory. Thus, in IIS, I have a mapping of .* to the aspnet_isapi.dll. And my web.config has an entry thusly: <add verb="*" path="*" type="HandlerClass, HandlerAssembly" /> And this is working just fine thus far. The handler gets all the requests and works like a...
1
1887
by: al jones | last post by:
As a learning exercise in VS 2005 - BASIC, I'm working on a program which may be run on any of the (hopefully) later versions of Windows - assume 98 - XP. Is there a quick / dirty way to determine which is the invalid character in the path / folder name? Given that, I can arbitrarily (arbitrary programmers, right!) replace it with a valid character (space or underscore or ...)
2
10960
by: Luis Arvayo | last post by:
I am compiling and executing c# code at runtime and I need to define in CompilerParameters.ReferencedAssemblies one of my own assemblies together with the standard System.dll u others. Example: // compiler options System.CodeDom.Compiler.CompilerParameters options = new System.CodeDom.Compiler.CompilerParameters(); options.GenerateExecutable = false; // result is a dll
11
2452
by: cdkorzen | last post by:
I'm sorry if this is a rehash, but all I see is the same info. Here's my debacle: I CAN get the PATH_INFO to work. With ANYTHING but ASP. Python, Perl, Cmd files... works fine. ASP can't find a file when extra path information is added. Is there a switch in ASP or something I can change that'll get it to work? Thanks!
8
11515
by: moondaddy | last post by:
I'm posting code for a user control ( FunctionConnectorSelector) below which has 3 content controls in it. each content control uses a style from a resource dictionary merged into the app.xaml file. each control has a border with another style, and each border has a unique path inside of it. I need to dynamically add these content controls using c# at runtime and am having trouble referencing the styles and adding the path into the...
0
9456
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...
1
9841
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
8712
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7244
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
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
5303
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
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
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
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.