Method of judging illegal characters in C # Chinese name or file path

Source: Internet
Author: User
This article mainly introduced the C # Chinese part name or the file path illegal character judgment method, this article mainly uses the built-in Getinvalidfilenamechars method to realize the illegal character judgment, needs the friend may refer to under

File path or save template illegal character judgment


1) NOT NULL judgment

?
1 2 3 4 5 6 7 string strtemplatename = Txttemplatename.text; if (string. Isnullorwhitespace (Strtemplatename)) {Show (Please enter the template name!) "," prompted, ". information, OK); Txttemplatename.focus (); Return }

2) and then to strtemplatename the illegal character judgment

?
1 2 3 4 5 6 7 if (Strtemplatename.indexofany (Path.getinvalidfilenamechars ()) >= 0) {//contains illegal characters/: *? "< > | Wait for show ("template name contains illegal characters, please re-enter", "error", errors, OK); Txttemplatename.focus (); Return }


3 The path refers to the system's IO dynamic library.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.