How to determine if a File Matches a File Mask?

后端 未结 13 1651
清歌不尽
清歌不尽 2020-12-14 07:14

I need to decide whether file name fits to file mask. The file mask could contain * or ? characters. Is there any simple solution for this?

bool bFits = Fits         


        
13条回答
  •  温柔的废话
    2020-12-14 07:23

    If PowerShell is available, it has direct support for wildcard type matching (as well as Regex).

    WildcardPattern pat = new WildcardPattern("a*.b*");
    if (pat.IsMatch(filename)) { ... }
    

提交回复
热议问题