0
當文件名中有空格時,以下代碼無法按預期工作。 Uri.AbsolutePath逃脫字符串,從而映射路徑上盤還包括不必要的轉義字符:在URI上使用Server.MapPath時處理轉義空格
var uri = new Uri("http://localhost/my file.txt");
var pathOnDisk = HttpContext.Current.Server.MapPath(uri.AbsolutePath);
// Resulting incorrectly in "C:\MyWebsite\my%20file.txt"
無碴左右,而使用官方的解決方案不與string.replace,一個人如何可以從轉義路徑uri,或者將路徑映射到磁盤而不使用轉義字符?
你會找到這裏的空間是子串並用的String.Empty替換 – SuncoastOwner