C# WindowsAPICodePack,传入非英文字符时"The path is not of a legal form"



当尝试使用WindowsAPICodePack从文件路径获取Shellfile时,(我用来获取缩略图(它工作正常,直到它传递一个具有非英语(特别是日语(文件名的文件。

using (FolderBrowserDialog SelFolder = new FolderBrowserDialog() )
{
if (SelFolder.ShowDialog() == System.Windows.Forms.DialogResult.OK )
{
Files = Directory.GetFiles(SelFolder.SelectedPath);
Files = Weld(Files, GetSubfolders(SelFolder.SelectedPath));
}
}

上面是我用来从文件夹及其子文件夹中获取每个文件的代码。

ShellFile shellFile = ShellFile.FromFilePath(Path.GetFullPath(Files[Count]));

然后这是引发异常的代码。它适用于 1000 多个文件,但仅在非英语字符上停止。特殊字符不会引发异常。我尝试使用Path.GetFullPath,因为它似乎可能有效,但可惜它没有。

我没有看到其他人有这个问题。有修复吗?

似乎实际上是一个 IndexOutOfRange 异常。在 for 循环中由 -1 固定

相关内容

最新更新