gpt4 book ai didi

c# - .Net 中的模式匹配与 IsolatedStorageFile.GetFileNames() 模式匹配一​​致

转载 作者:行者123 更新时间:2023-11-30 18:43:21 26 4
gpt4 key购买 nike

此 API 使用的模式匹配逻辑是否公开以在 .Net Framework 中的某处重用?

FilePatternMatch( string searchPattern, stringfileNameToTest ) 形式的东西是我要找的东西。

我正在为 WP7 实现一个临时解决方法,不过滤此过载的结果,我希望解决方案既能提供一致的体验,又能避免在公开时重新发明此功能。

如果不公开行为以供重用,正则表达式解决方案(如 glob pattern matching in .NET )就足够了,并且可以节省我测试行为应该是什么的精细细节的时间。

也许上面链接的线程中发布的答案之一是正确的。由于我还没有确认确切的行为,所以我无法一眼就确定这一点。如果您知道其中一个答案在行为上与问题标题中引用的 API 完全匹配,请随时指出我的答案。

我可以假设模式匹配与 DOS 处理 * 和 ? 的方式一致。在 8.3 文件名中(我熟悉该实现的行为细微差别),但可以合理地假设微软在十年以上的时间里已经发展了文件名的模式匹配行为,所以我认为我会在继续该假设之前进行检查。

最佳答案

IsolatedStorageFile.GetFileNames() 使用的模式匹配规则与 System.IO.Path 中使用的相同。他们都使用 Win32 API FindFirstFile/FindNextFile函数,即:

The directory or path, and the file name, which can include wildcard characters, for example, an asterisk (*) or a question mark (?).

This parameter should not be NULL, an invalid string (for example, an empty string or a string that is missing the terminating null character), or end in a trailing backslash ().

If the string ends with a wildcard, period (.), or directory name, the user must have access permissions to the root and all subdirectories on the path.

In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 widecharacters, call the Unicode version of the function and prepend "\?\" to the path. For more information, see Naming a File

.

关于c# - .Net 中的模式匹配与 IsolatedStorageFile.GetFileNames() 模式匹配一​​致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4532898/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com