Validate folder name in C#

前端 未结 3 989
夕颜
夕颜 2020-12-19 05:55

I need to validate a folder name in c#.

I have tried the following regex :

 ^(.*?/|.*?\\\\)?([^\\./|^\\.\\\\]+)(?:\\.([^\\\\]*)|)$
<
3条回答
  •  无人及你
    2020-12-19 05:55

    Validating a folder name correctly can be quite a mission. See my blog post Taking data binding, validation and MVVM to the next level - part 2.
    Don't be fooled by the title, it's about validating file system paths, and it illustrates some of the complexities involved in using the methods provided in the .Net framework. While you may want to use a regex, it isn't the most reliable way to do the job.

提交回复
热议问题