c# – Uri.AbsolutePath与空格混合路径
发布时间:2020-12-15 03:53:55 所属栏目:百科 来源:网络整理
导读:在WinApp中,我只是想从Uri对象中获取绝对路径: Uri myUri = new Uri(myPath); //myPath is a string//somewhere else in the codestring path = myUri.AbsolutePath; 如果我的原始路径中没有空格,这可以正常工作.如果空格在那里,那么字符串就会被破坏;例如
在WinApp中,我只是想从Uri对象中获取绝对路径:
Uri myUri = new Uri(myPath); //myPath is a string //somewhere else in the code string path = myUri.AbsolutePath; 如果我的原始路径中没有空格,这可以正常工作.如果空格在那里,那么字符串就会被破坏;例如“文件和设置”成为“文档和设置”等 任何帮助将不胜感激! 编辑: 解决方法
它是编码它应该,你可能UrlDecode它得到它与空格,但它不是“被破坏”它只是正确的编码.
我不知道你在写什么,但是在asp.net中转换它是Server.UrlDecode(路径).您也可以使用LocalPath,而不是AbsolutePath,如果它是Windows应用程序. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |