我的路径有点问题:
"D:\\Music\\DJ Ti%C3%ABsto\\Tiesto\\Adagio For Strings (Spirit of London).mp3" "D:\\Music\\Dj Tiësto\\Tiesto\\Adagio For Strings (Spirit of London).mp3"目前,当它将该路径发送到我的音频库时,它无法打开路径。 (它崩溃的原因是试图将-1分配给轨迹栏......但它无关紧要)。
所以我想知道,无论如何都要阻止C#用%[code]切换特殊字符? 我为“[”和“]”做了一个.Replace,但我不必查找每个特殊字符,并添加一行代码来防止它。 有没有办法解决?
I have a slight problem with a path:
"D:\\Music\\DJ Ti%C3%ABsto\\Tiesto\\Adagio For Strings (Spirit of London).mp3" "D:\\Music\\Dj Tiësto\\Tiesto\\Adagio For Strings (Spirit of London).mp3"Currently, when it sends that path to my Audio Library, it cannot open the path. (the reason for it crashing is trying to assign a -1 to a trackbar...but it's irrelevant).
So I'm wondering, is there anyway to prevent C# from switching special characters with %[code]? I've done a .Replace for "[" and "]", but I rather not have to look up every single special character, and add a line of code to prevent it. Is there anyway around this?
最满意答案
调用Uri.UnescapeDataString 。
顺便说一下,当把路径放在字符串中时,你可以在字符串前放一个@符号来告诉编译器不要处理转义码,如下所示: @"D:\Music\DJ Tiësto\Tiesto\Adagio For Strings (Spirit of London).mp3" 。 这样,您不需要将每个反斜杠加倍。
Call Uri.UnescapeDataString.
By the way, when putting paths in strings, you can put an @ sign before the string to tell the compiler not to process escape codes, like this: @"D:\Music\DJ Tiësto\Tiesto\Adagio For Strings (Spirit of London).mp3". This way, you don't need to double up every backslash.
更多推荐
code,路径,path,电脑培训,计算机培训,IT培训"/> <meta name="description"
发布评论