The URL is HttpUtility. UrlEncode, which converts the space to the "+" number. If you find the cause, you can solve the Bug.
Reference:
Copy codeThe Code is as follows:
FileName = HttpUtility. UrlEncode (fileName, Encoding. UTF8 );
FileName = fileName. Replace ("+", "% 20 ");
It is solved through Replace replacement. Although the problem is solved, this is not a good method. If the folder or file name contains the "+" number, it will lead to another Bug.
Best Solution:
Use HttpUtility. UrlPathEncode and UrlPathEncode to perform the following steps:
1. Apply the encoding logic of the UrlPathEncode method only to the URL path section (excluding the query string ). This method assumes that the URL is encoded as a UTF-8 string.
2. Non-space encoding to use a subset of the first 128 ASCII characters in the resulting encoding string. All characters in Unicode are 128 or higher, or 32 or smaller, and are entered in the URL.
3. Enter a space as % 20.
You can enter a URL using the UrlEncode or UrlPathEncode method. However, the method returns different results. The UrlEncode method converts each space character to the plus sign (+) character. The UrlPathEncode method converts each space character into a string % 20, representing a space in hexadecimal notation. The UrlPathEncode method is used to partially encode the URL path to ensure consistent decoded URLs, regardless of the platform or browser that performs decoding. When you use the UrlPathEncode method, the query string value is not input. Therefore, you can use any question mark value (?) In the string, no input will be made. If the URL is required, the UrlEncode method is used when the string is queried.
Many pages in the project use the Replace method. After the query, Replace all the pages with UrlPathEncode to reduce the occurrence of more bugs.