简体   繁体   中英

C# WindowsAPICodePack, “The path is not of a legal form” when passing in non-english characters

When trying to get a Shellfile from file path using WindowsAPICodePack, (Which I use to get a thumbnail from) it works fine until it gets passed a file with a non-english (specifically Japanese) filename.

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

Up there is the code I use to get every file from a folder and its subfolders.

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

And then this is the code that throws an exception. It runs fine for over 1000 files, but only stops on Non-English characters. Special characters do not throw an exception. I tried using Path.GetFullPath as it seemed like it might've worked but alas it didn't.

I don't see anyone else with this problem. Is there a fix?

Seems to actually have been an IndexOutOfRange Exception. Fixed by -1 on a for loop

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM